blob: c045c2584e7cb4f84ec39c003695c158d7a1ee84 [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* 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 Lobodzinskid4950072017-08-01 13:02:20 -06005 *
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 Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 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 Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 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 Lobodzinski5d8244a2020-01-23 13:00:43 -070059 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 Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 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 Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // 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 Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 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 Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
121void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700122 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700123 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700124 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700125 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
126 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700128 // 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-LunarG152a88b2019-03-20 15:42:24 -0600133 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700134 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-LunarG152a88b2019-03-20 15:42:24 -0600140 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700141 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-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
150 }
151
Jason Macnak5c954952019-07-09 15:46:12 -0700152 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);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500157 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
158 }
159
160 if (device_extensions.vk_khr_ray_tracing) {
161 // Get the needed ray tracing limits
162 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700166 }
167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700168 if (device_extensions.vk_ext_transform_feedback) {
169 // Get the needed transform feedback limits
170 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
171 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
172 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
173 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
174 }
175
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800176 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 // Save app-enabled features in this device's validation object
179 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
181 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
182 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 if (features2) {
184 tmp_features2_state.features = features2->features;
185 } else if (pCreateInfo->pEnabledFeatures) {
186 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200188 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200190 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700191 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200192 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700193}
194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500196 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600197 bool skip = false;
198
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200199 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
200 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
201 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
205 skip |=
206 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
207 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
208 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
209 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600210 }
211
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700213 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
214 bool negative_viewport =
215 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200216 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700217 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
218 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
219 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600223 {
224 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
225 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
226 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700227 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
228 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
229 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 }
231 }
232
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
234 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600235 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
236 if (features2) {
237 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700238 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700239 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
240 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600241 }
242 }
243
Locke77fad1c2019-04-16 13:09:03 -0600244 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
245 if (features2) {
246 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700247 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
248 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
249 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600250 }
251 }
252
253 auto vertex_attribute_divisor_features =
254 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
255 if (vertex_attribute_divisor_features) {
256 bool extension_found = false;
257 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
258 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
259 VK_MAX_EXTENSION_NAME_SIZE)) {
260 extension_found = true;
261 break;
262 }
263 }
264 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700265 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
266 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
267 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600268 }
269 }
270
Tony-LunarG28017bc2020-01-23 14:40:25 -0700271 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
272 if (vulkan_11_features) {
273 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
274 while (current) {
275 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
276 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
277 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
278 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
279 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
280 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700281 skip |= LogError(
282 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700283 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
284 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
285 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
286 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
287 break;
288 }
289 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
290 }
291 }
292
293 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
294 if (vulkan_12_features) {
295 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
296 while (current) {
297 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
298 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
299 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
300 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
301 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
302 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
303 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
304 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700310 skip |= LogError(
311 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700312 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
313 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
314 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
315 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
316 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
317 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
318 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
319 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
320 break;
321 }
322 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
323 }
324 }
325
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600326 // Validate pCreateInfo->pQueueCreateInfos
327 if (pCreateInfo->pQueueCreateInfos) {
328 std::unordered_set<uint32_t> set;
329
330 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700331 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
332 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700334 skip |=
335 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
336 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
337 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
338 "index value.",
339 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600340 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700341 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
342 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
343 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
344 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600345 } else {
346 set.insert(requested_queue_family);
347 }
348
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700349 if (queue_create_info.pQueuePriorities != nullptr) {
350 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
351 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600352 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700353 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
354 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
355 "] (=%f) is not between 0 and 1 (inclusive).",
356 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600357 }
358 }
359 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700360
361 // Need to know if protectedMemory feature is passed in preCall to creating the device
362 VkBool32 protectedMemory = VK_FALSE;
363 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
364 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
365 if (protected_features) {
366 protectedMemory = protected_features->protectedMemory;
367 } else if (vulkan_11_features) {
368 protectedMemory = vulkan_11_features->protectedMemory;
369 }
370 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
371 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
372 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
373 "protectedMemory feature being set as well.");
374 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600375 }
376 }
377
378 return skip;
379}
380
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500381bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700382 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700383 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
384 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
385 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 }
387
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700388 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600389}
390
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700391bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500392 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100393 bool skip = false;
394
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600395 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700396 skip |=
397 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600398
399 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
400 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
401 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
402 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700403 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
404 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
405 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600406 }
407
408 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
409 // queueFamilyIndexCount uint32_t values
410 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700411 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
412 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
413 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
414 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600415 }
416 }
417
418 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
419 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
420 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
421 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700422 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
423 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
424 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600425 }
426 }
427
428 return skip;
429}
430
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700431bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500432 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600433 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434
435 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600436 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
437 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
438 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
439 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700440 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
441 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
442 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 }
444
445 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
446 // queueFamilyIndexCount uint32_t values
447 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
449 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
450 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
451 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454
Dave Houlton413a6782018-05-22 13:01:54 -0600455 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700456 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600457 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700458 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600459 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700460 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600461
Dave Houlton413a6782018-05-22 13:01:54 -0600462 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600464 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700465 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466
Dave Houlton130c0212018-01-29 13:39:56 -0700467 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700468 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
469 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700470 skip |= LogError(
471 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600472 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
473 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700474 }
475
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600476 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100477 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
478 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
480 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
481 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482 }
483
484 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100485 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
486 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
488 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
489 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
490 ") are not equal.",
491 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100492 }
493
494 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700495 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
496 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
497 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
498 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100499 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500 }
501
502 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700503 skip |= LogError(
504 device, "VUID-VkImageCreateInfo-imageType-00957",
505 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 }
507 }
508
Dave Houlton130c0212018-01-29 13:39:56 -0700509 // 3D image may have only 1 layer
510 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
512 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700513 }
514
515 // If multi-sample, validate type, usage, tiling and mip levels.
516 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
517 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600518 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700519 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
520 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700521 }
522
523 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
524 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
525 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
526 // At least one of the legal attachment bits must be set
527 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700528 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
529 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700530 }
531 // No flags other than the legal attachment bits may be set
532 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
533 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700534 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
535 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700536 }
537 }
538
Jeff Bolzef40fec2018-09-01 22:04:34 -0500539 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500541 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600542 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
543 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500544 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600545 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700546 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
547 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
548 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600551 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
553 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
554 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600555 }
556
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700557 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700558 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
559 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
560 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100561 }
562
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600563 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
564 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
565 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
566 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
568 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
569 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 }
571
572 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
573 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
574 // Linear tiling is unsupported
575 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, kVUID_PVError_InvalidUsage,
577 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
578 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600579 }
580
581 // Sparse 1D image isn't valid
582 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700583 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
584 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 }
586
587 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700588 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700589 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
590 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
591 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600592 }
593
594 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700595 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
597 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
598 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 }
600
601 // Multi-sample 2D image when device doesn't support it
602 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700603 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600604 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700605 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
606 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
607 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700608 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
611 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
612 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700613 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
616 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
617 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700618 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700620 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
621 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
622 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600623 }
624 }
625 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500626
Jeff Bolz9af91c52018-09-01 21:53:57 -0500627 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
628 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
630 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
631 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500632 }
633 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
635 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
636 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500637 }
638 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700639 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
640 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
641 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500642 }
643 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500644
645 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600646 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700647 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
648 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
649 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500650 }
651
Dave Houlton142c4cb2018-10-17 15:04:41 -0600652 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
654 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
655 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
656 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500657 }
658
Dave Houlton142c4cb2018-10-17 15:04:41 -0600659 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
661 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
662 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
663 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500664 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600665 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700666 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
667 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
668 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
669 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500670 }
671 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500672
sfricke-samsung8f658d42020-05-03 20:12:24 -0700673 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
674 (FormatHasDepth(pCreateInfo->format) == false)) {
675 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
676 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
677 "format must be a depth or depth/stencil format.");
678 }
679
Andrew Fobel3abeb992020-01-20 16:33:22 -0500680 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
681 if (image_stencil_struct != nullptr) {
682 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
683 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
684 // No flags other than the legal attachment bits may be set
685 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
686 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
688 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
689 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
690 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500691 }
692 }
693
694 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
695 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
696 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
697 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700698 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
699 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
700 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
701 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500702 }
703
704 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
705 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700706 LogError(device, "VUID-VkImageCreateInfo-format-02537",
707 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
708 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
709 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500710 }
711 }
712
713 if (!physical_device_features.shaderStorageImageMultisample &&
714 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
715 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
716 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 LogError(device, "VUID-VkImageCreateInfo-format-02538",
718 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
719 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
720 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500721 }
722
723 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
724 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(
726 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500727 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
728 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
729 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
730 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
731 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(
733 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500734 "vkCreateImage(): Depth-stencil image in which usage does not include "
735 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
736 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
737 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
738 }
739
740 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
741 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(
743 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500744 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
745 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
746 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
747 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
748 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(
750 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500751 "vkCreateImage(): Depth-stencil image in which usage does not include "
752 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
753 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
754 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
755 }
756 }
757 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700758
759 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
760 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
761 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
762 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
763 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
764 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700765
766 if (device_extensions.vk_ext_image_drm_format_modifier) {
767 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
768 const auto drm_format_mod_explict =
769 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
770 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
771 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
772 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
773 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
774 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
775 "either VkImageDrmFormatModifierListCreateInfoEXT or "
776 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
777 }
778 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
779 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
780 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
781 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
782 "in the pNext chain");
783 }
784 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600785 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500786
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600787 return skip;
788}
789
Jeff Bolz99e3f632020-03-24 22:59:22 -0500790bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
791 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
792 bool skip = false;
793
794 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700795 // Validate feature set if using CUBE_ARRAY
796 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
797 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
798 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
799 "enabling the imageCubeArray feature.");
800 }
801
Jeff Bolz99e3f632020-03-24 22:59:22 -0500802 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
803 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
804 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700805 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500806 pCreateInfo->subresourceRange.layerCount);
807 }
808 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700809 skip |= LogError(
810 device, "VUID-VkImageViewCreateInfo-viewType-02961",
811 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
812 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500813 }
814 }
815 }
816 return skip;
817}
818
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600819bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100821 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100822
823 // Note: for numerical correctness
824 // - float comparisons should expect NaN (comparison always false).
825 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
826
827 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700828 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100829 if (v1_f <= 0.0f) return true;
830
831 float intpart;
832 const float fract = modff(v1_f, &intpart);
833
834 assert(std::numeric_limits<float>::radix == 2);
835 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
836 if (intpart >= u32_max_plus1) return false;
837
838 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
839 if (v1_u32 < v2_u32)
840 return true;
841 else if (v1_u32 == v2_u32 && fract == 0.0f)
842 return true;
843 else
844 return false;
845 };
846
847 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
848 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
849 return (v1_f <= v2_f);
850 };
851
852 // width
853 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700854 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100855
856 if (!(viewport.width > 0.0f)) {
857 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
859 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100860 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
861 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700862 skip |= LogError(object, "VUID-VkViewport-width-01771",
863 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
864 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100865 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogWarning(object, kVUID_PVError_NONE,
867 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
868 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
869 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870 }
871
872 // height
873 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700874 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700875 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100876
877 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
878 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700879 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
880 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100881 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
882 height_healthy = false;
883
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogError(object, "VUID-VkViewport-height-01773",
885 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
886 ").",
887 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100888 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
889 height_healthy = false;
890
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700891 skip |= LogWarning(
892 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100893 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600894 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600895 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100896 }
897
898 // x
899 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700900 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100901 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700902 skip |= LogError(object, "VUID-VkViewport-x-01774",
903 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
904 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100905 }
906
907 // x + width
908 if (x_healthy && width_healthy) {
909 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700910 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700911 skip |= LogError(
912 object, "VUID-VkViewport-x-01232",
913 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
914 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
915 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100916 }
917 }
918
919 // y
920 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700921 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100922 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(object, "VUID-VkViewport-y-01775",
924 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
925 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700926 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100927 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700928 skip |= LogError(object, "VUID-VkViewport-y-01776",
929 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
930 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100931 }
932
933 // y + height
934 if (y_healthy && height_healthy) {
935 const float boundary = viewport.y + viewport.height;
936
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700937 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700938 skip |= LogError(object, "VUID-VkViewport-y-01233",
939 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
940 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
941 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700942 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600943 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700944 LogError(object, "VUID-VkViewport-y-01777",
945 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
946 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
947 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100948 }
949 }
950
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700951 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100952 // minDepth
953 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700954 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600955
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700956 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
957 "[0.0, 1.0] range.",
958 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100959 }
960
961 // maxDepth
962 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700963 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600964
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700965 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
966 "[0.0, 1.0] range.",
967 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100968 }
969 }
970
971 return skip;
972}
973
Dave Houlton142c4cb2018-10-17 15:04:41 -0600974struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500975 VkShadingRatePaletteEntryNV shadingRate;
976 uint32_t width;
977 uint32_t height;
978};
979
980// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600981static SampleOrderInfo sampleOrderInfos[] = {
982 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
983 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
984 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
985 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
986 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
987 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500988};
989
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500990bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500991 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500992
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500993 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500994 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500995 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500996 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500997 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500998 break;
999 }
1000 }
1001
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001002 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001003 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1004 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1005 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001006 return skip;
1007 }
1008
Dave Houlton142c4cb2018-10-17 15:04:41 -06001009 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001010 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001011 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1012 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1013 ") must "
1014 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1015 "is set in framebufferNoAttachmentsSampleCounts.",
1016 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001017 }
1018
Jeff Bolz9af91c52018-09-01 21:53:57 -05001019 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001020 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1021 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1022 ") must "
1023 "be equal to the product of sampleCount (=%" PRIu32
1024 "), the fragment width for shadingRate "
1025 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1026 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001027 }
1028
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001029 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001030 skip |= LogError(
1031 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001032 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1033 ") must "
1034 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001035 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001036 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001037
1038 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001039 // the first width*height*sampleCount bits to all be set. Note: There is no
1040 // guarantee that 64 bits is enough, but practically it's unlikely for an
1041 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001042 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001043 uint64_t sampleLocationsMask = 0;
1044 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1045 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1046 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001047 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1048 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001049 }
1050 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001051 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1052 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001053 }
1054 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001055 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1056 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001057 }
1058 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1059 sampleLocationsMask |= 1ULL << idx;
1060 }
1061
1062 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1063 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001064 skip |= LogError(
1065 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001066 "The array pSampleLocations must contain exactly one entry for "
1067 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001068 }
1069
1070 return skip;
1071}
1072
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001073bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1074 uint32_t createInfoCount,
1075 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1076 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001077 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001078 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001079
1080 if (pCreateInfos != nullptr) {
1081 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001082 bool has_dynamic_viewport = false;
1083 bool has_dynamic_scissor = false;
1084 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001085 bool has_dynamic_depth_bias = false;
1086 bool has_dynamic_blend_constant = false;
1087 bool has_dynamic_depth_bounds = false;
1088 bool has_dynamic_stencil_compare = false;
1089 bool has_dynamic_stencil_write = false;
1090 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001091 bool has_dynamic_viewport_w_scaling_nv = false;
1092 bool has_dynamic_discard_rectangle_ext = false;
1093 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001094 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001095 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001096 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001097 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001098 if (pCreateInfos[i].pDynamicState != nullptr) {
1099 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1100 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1101 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001102 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1103 if (has_dynamic_viewport == true) {
1104 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1105 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1106 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1107 i);
1108 }
1109 has_dynamic_viewport = true;
1110 }
1111 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1112 if (has_dynamic_scissor == true) {
1113 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1114 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1115 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1116 i);
1117 }
1118 has_dynamic_scissor = true;
1119 }
1120 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1121 if (has_dynamic_line_width == true) {
1122 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1123 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1124 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1125 i);
1126 }
1127 has_dynamic_line_width = true;
1128 }
1129 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1130 if (has_dynamic_depth_bias == true) {
1131 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1132 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1133 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1134 i);
1135 }
1136 has_dynamic_depth_bias = true;
1137 }
1138 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1139 if (has_dynamic_blend_constant == true) {
1140 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1141 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1142 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1143 i);
1144 }
1145 has_dynamic_blend_constant = true;
1146 }
1147 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1148 if (has_dynamic_depth_bounds == true) {
1149 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1150 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1151 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1152 i);
1153 }
1154 has_dynamic_depth_bounds = true;
1155 }
1156 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1157 if (has_dynamic_stencil_compare == true) {
1158 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1159 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1160 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1161 i);
1162 }
1163 has_dynamic_stencil_compare = true;
1164 }
1165 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1166 if (has_dynamic_stencil_write == true) {
1167 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1168 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1169 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1170 i);
1171 }
1172 has_dynamic_stencil_write = true;
1173 }
1174 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1175 if (has_dynamic_stencil_reference == true) {
1176 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1177 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1178 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1179 i);
1180 }
1181 has_dynamic_stencil_reference = true;
1182 }
1183 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1184 if (has_dynamic_viewport_w_scaling_nv == true) {
1185 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1186 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1187 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1188 i);
1189 }
1190 has_dynamic_viewport_w_scaling_nv = true;
1191 }
1192 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1193 if (has_dynamic_discard_rectangle_ext == true) {
1194 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1195 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1196 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1197 i);
1198 }
1199 has_dynamic_discard_rectangle_ext = true;
1200 }
1201 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1202 if (has_dynamic_sample_locations_ext == true) {
1203 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1204 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1205 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1206 i);
1207 }
1208 has_dynamic_sample_locations_ext = true;
1209 }
1210 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1211 if (has_dynamic_exclusive_scissor_nv == true) {
1212 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1213 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1214 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1215 i);
1216 }
1217 has_dynamic_exclusive_scissor_nv = true;
1218 }
1219 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1220 if (has_dynamic_shading_rate_palette_nv == true) {
1221 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1222 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1223 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1224 i);
1225 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001226 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001227 }
1228 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1229 if (has_dynamic_viewport_course_sample_order_nv == true) {
1230 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1231 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1232 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1233 i);
1234 }
1235 has_dynamic_viewport_course_sample_order_nv = true;
1236 }
1237 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1238 if (has_dynamic_line_stipple == true) {
1239 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1240 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1241 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1242 i);
1243 }
1244 has_dynamic_line_stipple = true;
1245 }
Petr Kraus299ba622017-11-24 03:09:03 +01001246 }
1247 }
1248
Peter Chen85366392019-05-14 15:20:11 -04001249 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1250 if ((feedback_struct != nullptr) &&
1251 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001252 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1253 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1254 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1255 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1256 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001257 }
1258
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001259 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001260
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001261 // Collect active stages and other information
1262 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001263 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001264 bool has_eval = false;
1265 bool has_control = false;
1266 if (pCreateInfos[i].pStages != nullptr) {
1267 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1268 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1269
1270 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1271 has_control = true;
1272 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1273 has_eval = true;
1274 }
1275
1276 skip |= validate_string(
1277 "vkCreateGraphicsPipelines",
1278 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1279 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1280 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001281 }
1282
1283 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1284 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1285 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1286 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1287 pCreateInfos[i].pTessellationState,
1288 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1289 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1290
1291 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1292 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1293
1294 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1295 "VkPipelineTessellationDomainOriginStateCreateInfo",
1296 pCreateInfos[i].pTessellationState->pNext,
1297 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1298 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001299 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1300 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001301
1302 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1303 pCreateInfos[i].pTessellationState->flags,
1304 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1305 }
1306
1307 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1308 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1309 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1310 pCreateInfos[i].pInputAssemblyState,
1311 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1312 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1313
1314 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1315 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001316 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001317
1318 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1319 pCreateInfos[i].pInputAssemblyState->flags,
1320 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1321
1322 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1323 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1324 pCreateInfos[i].pInputAssemblyState->topology,
1325 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1326
1327 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1328 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1329 }
1330
1331 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001332 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001333
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001334 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001335 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1336 "vkCreateGraphicsPipelines: pararameter "
1337 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1338 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001339 }
1340
1341 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1342 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1343 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1344 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1345 pCreateInfos[i].pVertexInputState->pNext, 1,
1346 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001347 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1348 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001349 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1350 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001351 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001352 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1353 skip |=
1354 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1355 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1356 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1357 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1358 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1359
1360 skip |= validate_array(
1361 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1362 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1363 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1364 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1365
1366 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1367 for (uint32_t vertexBindingDescriptionIndex = 0;
1368 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1369 ++vertexBindingDescriptionIndex) {
1370 skip |= validate_ranged_enum(
1371 "vkCreateGraphicsPipelines",
1372 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1373 AllVkVertexInputRateEnums,
1374 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1375 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1376 }
1377 }
1378
1379 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1380 for (uint32_t vertexAttributeDescriptionIndex = 0;
1381 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1382 ++vertexAttributeDescriptionIndex) {
1383 skip |= validate_ranged_enum(
1384 "vkCreateGraphicsPipelines",
1385 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1386 AllVkFormatEnums,
1387 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1388 "VUID-VkVertexInputAttributeDescription-format-parameter");
1389 }
1390 }
1391
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001392 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001393 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1394 "vkCreateGraphicsPipelines: pararameter "
1395 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1396 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1397 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001398 }
1399
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001400 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001401 skip |=
1402 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1403 "vkCreateGraphicsPipelines: pararameter "
1404 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1405 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1406 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001407 }
1408
1409 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001410 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1411 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001412 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1413 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001414 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1415 "vkCreateGraphicsPipelines: parameter "
1416 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1417 "(%" PRIu32 ") is not distinct.",
1418 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001419 }
1420 vertex_bindings.insert(vertex_bind_desc.binding);
1421
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001422 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001423 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1424 "vkCreateGraphicsPipelines: parameter "
1425 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1426 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1427 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001428 }
1429
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001430 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001431 skip |=
1432 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1433 "vkCreateGraphicsPipelines: parameter "
1434 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1435 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1436 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001437 }
1438 }
1439
Peter Kohautc7d9d392018-07-15 00:34:07 +02001440 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001441 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1442 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001443 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1444 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001445 skip |= LogError(
1446 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001447 "vkCreateGraphicsPipelines: parameter "
1448 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1449 i, d, vertex_attrib_desc.location);
1450 }
1451 attribute_locations.insert(vertex_attrib_desc.location);
1452
1453 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1454 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001455 skip |= LogError(
1456 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001457 "vkCreateGraphicsPipelines: parameter "
1458 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1459 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1460 i, d, vertex_attrib_desc.binding, i);
1461 }
1462
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001463 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1465 "vkCreateGraphicsPipelines: parameter "
1466 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1467 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1468 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001469 }
1470
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001471 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001472 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1473 "vkCreateGraphicsPipelines: parameter "
1474 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1475 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1476 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001477 }
1478
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001479 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001480 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1481 "vkCreateGraphicsPipelines: parameter "
1482 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1483 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1484 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001485 }
1486 }
1487 }
1488
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001489 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1490 if (has_control && has_eval) {
1491 if (pCreateInfos[i].pTessellationState == nullptr) {
1492 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1493 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1494 "shader stage and a tessellation evaluation shader stage, "
1495 "pCreateInfos[%d].pTessellationState must not be NULL.",
1496 i, i);
1497 } else {
1498 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1499 skip |= validate_struct_pnext(
1500 "vkCreateGraphicsPipelines",
1501 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1502 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1503 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1504 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001505
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001506 skip |= validate_reserved_flags(
1507 "vkCreateGraphicsPipelines",
1508 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1509 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001510
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001511 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1512 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1513 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1514 "vkCreateGraphicsPipelines: invalid parameter "
1515 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1516 "should be >0 and <=%u.",
1517 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1518 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001519 }
1520 }
1521 }
1522
1523 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1524 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1525 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1526 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001527 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1528 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1529 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1530 "].pViewportState (=NULL) is not a valid pointer.",
1531 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001532 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001533 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1534
1535 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001536 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1537 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1538 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1539 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001540 }
1541
Petr Krausa6103552017-11-16 21:21:58 +01001542 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1543 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001544 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1545 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001546 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1547 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001548 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001549 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001550 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001551 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001552 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001553 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1554 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001555 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001556 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1557 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001558
1559 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001560 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001561 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001562 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001563
Dave Houlton142c4cb2018-10-17 15:04:41 -06001564 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1565 pCreateInfos[i].pViewportState->pNext);
1566 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1567 pCreateInfos[i].pViewportState->pNext);
1568 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1569 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001570 const auto vp_swizzle_struct =
1571 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001572 const auto vp_w_scaling_struct =
1573 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001574
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001575 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001576 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001577 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1578 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1579 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1580 ") is not 1.",
1581 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001582 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001583
Petr Krausa6103552017-11-16 21:21:58 +01001584 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001585 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1586 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1587 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1588 ") is not 1.",
1589 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001590 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001591
Dave Houlton142c4cb2018-10-17 15:04:41 -06001592 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1593 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001594 skip |= LogError(
1595 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1596 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1597 "disabled, but pCreateInfos[%" PRIu32
1598 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1599 ") is not 1.",
1600 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001601 }
1602
Jeff Bolz9af91c52018-09-01 21:53:57 -05001603 if (shading_rate_image_struct &&
1604 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001605 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1606 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1607 "disabled, but pCreateInfos[%" PRIu32
1608 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1609 ") is neither 0 nor 1.",
1610 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001611 }
1612
Petr Krausa6103552017-11-16 21:21:58 +01001613 } else { // multiViewport enabled
1614 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001615 skip |= LogError(
1616 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001617 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001618 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001619 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1620 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1621 "].pViewportState->viewportCount (=%" PRIu32
1622 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1623 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001624 }
Petr Krausa6103552017-11-16 21:21:58 +01001625
1626 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001627 skip |= LogError(
1628 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001629 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001630 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001631 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1632 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1633 "].pViewportState->scissorCount (=%" PRIu32
1634 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1635 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001636 }
1637 }
1638
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001639 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001640 skip |=
1641 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1642 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1643 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1644 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001645 }
1646
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001647 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001648 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1649 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1650 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1651 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1652 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001653 }
1654
Petr Krausa6103552017-11-16 21:21:58 +01001655 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001656 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1657 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1658 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1659 "].pViewportState->viewportCount (=%" PRIu32 ").",
1660 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001661 }
1662
Dave Houlton142c4cb2018-10-17 15:04:41 -06001663 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001664 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001665 skip |=
1666 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1667 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1668 ") must be zero or identical to pCreateInfos[%" PRIu32
1669 "].pViewportState->viewportCount (=%" PRIu32 ").",
1670 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001671 }
1672
Dave Houlton142c4cb2018-10-17 15:04:41 -06001673 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001674 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001675 skip |= LogError(
1676 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001677 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1678 "] "
1679 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1680 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1681 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001682 }
1683
Petr Krausa6103552017-11-16 21:21:58 +01001684 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001685 skip |= LogError(
1686 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001687 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1688 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001689 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1690 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001691 }
1692
1693 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001694 skip |= LogError(
1695 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001696 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1697 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001698 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1699 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001700 }
1701
Jeff Bolz3e71f782018-08-29 23:15:45 -05001702 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001703 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1704 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1705 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001706 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1707 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1708 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1709 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1710 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001711 }
1712
Jeff Bolz9af91c52018-09-01 21:53:57 -05001713 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001714 shading_rate_image_struct->viewportCount > 0 &&
1715 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001716 skip |= LogError(
1717 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001718 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001719 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1720 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001721 i, i);
1722 }
1723
Chris Mayer328d8212018-12-11 14:16:18 +01001724 if (vp_swizzle_struct) {
1725 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001726 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1727 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1728 " does "
1729 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1730 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001731 }
1732 }
1733
Petr Krausb3fcdb42018-01-09 22:09:09 +01001734 // validate the VkViewports
1735 if (!has_dynamic_viewport && viewport_state.pViewports) {
1736 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1737 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001738 const char *fn_name = "vkCreateGraphicsPipelines";
1739 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1740 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1741 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001742 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001743 }
1744 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001745
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001746 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001747 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1748 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1749 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1750 "VK_NV_clip_space_w_scaling extension is not enabled.",
1751 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001752 }
1753
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001754 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001755 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1756 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1757 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1758 "VK_EXT_discard_rectangles extension is not enabled.",
1759 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001760 }
1761
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001762 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001763 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1764 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1765 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1766 "VK_EXT_sample_locations extension is not enabled.",
1767 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001768 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001769
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001770 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001771 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1772 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1773 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1774 "VK_NV_scissor_exclusive extension is not enabled.",
1775 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001776 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001777
1778 if (coarse_sample_order_struct &&
1779 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1780 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001781 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1782 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1783 "] "
1784 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1785 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1786 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001787 }
1788
1789 if (coarse_sample_order_struct) {
1790 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001791 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001792 }
1793 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001794
1795 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1796 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001797 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1798 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1799 "] "
1800 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1801 ") "
1802 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1803 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001804 }
1805 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001806 skip |= LogError(
1807 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001808 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1809 "] "
1810 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1811 i);
1812 }
1813 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001814 }
1815
1816 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001817 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1818 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1819 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1820 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001821 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001822 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1823 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1824 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001825 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001826 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001827 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001828 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001829 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001830 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001831 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001832 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1833 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001834
1835 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001836 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001837 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001838 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001839
1840 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001841 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001842 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1843 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1844
1845 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001846 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001847 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1848 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001849 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001850 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001851
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001852 skip |= validate_flags(
1853 "vkCreateGraphicsPipelines",
1854 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1855 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001856 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001857
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001858 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001859 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001860 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1861 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1862
1863 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001864 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001865 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1866 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1867
1868 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001869 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1870 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1871 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1872 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001873 }
John Zulauf7acac592017-11-06 11:15:53 -07001874 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001875 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001876 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1877 "vkCreateGraphicsPipelines(): parameter "
1878 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1879 i);
John Zulauf7acac592017-11-06 11:15:53 -07001880 }
1881 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1882 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1883 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001884 skip |= LogError(
1885 device,
1886
Dave Houlton413a6782018-05-22 13:01:54 -06001887 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001888 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001889 }
1890 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001891
1892 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1893 pCreateInfos[i].pRasterizationState->pNext);
1894
1895 if (line_state) {
1896 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1897 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1898 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1899 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1901 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1902 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1903 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001904 }
1905 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1906 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001907 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1908 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1909 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1910 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001911 }
1912 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1913 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001914 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1915 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1916 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1917 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001918 }
1919 }
1920 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1921 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1922 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001923 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1924 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1925 "range [1,256].",
1926 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001927 }
1928 }
1929 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001930 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001931 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1932 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001933 skip |=
1934 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1935 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1936 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1937 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001938 }
1939 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1940 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 skip |=
1942 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1943 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1944 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1945 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001946 }
1947 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1948 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001949 skip |=
1950 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1951 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1952 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1953 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001954 }
1955 if (line_state->stippledLineEnable) {
1956 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1957 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001958 skip |=
1959 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1960 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1961 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1962 "stippledRectangularLines feature.",
1963 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001964 }
1965 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1966 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001967 skip |=
1968 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1969 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1970 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1971 "stippledBresenhamLines feature.",
1972 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001973 }
1974 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1975 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001976 skip |=
1977 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1978 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1979 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1980 "stippledSmoothLines feature.",
1981 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001982 }
1983 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1984 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001985 skip |=
1986 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1987 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1988 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1989 "stippledRectangularLines and strictLines features.",
1990 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001991 }
1992 }
1993 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 }
1995
Petr Krause91f7a12017-12-14 20:57:36 +01001996 bool uses_color_attachment = false;
1997 bool uses_depthstencil_attachment = false;
1998 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001999 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002000 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2001 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002002 const auto &subpasses_uses = subpasses_uses_it->second;
2003 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2004 uses_color_attachment = true;
2005 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2006 uses_depthstencil_attachment = true;
2007 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002008 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002009 }
2010
2011 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002013 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002014 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002015 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002016 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002017
2018 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002019 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002020 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002021 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002022
2023 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002024 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2026 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2027
2028 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002029 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002030 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2031 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2032
2033 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002034 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002035 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2036 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002037 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002038
2039 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002040 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002041 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2042 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2043
2044 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002045 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002046 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2047 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2048
2049 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002050 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002051 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2052 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002053 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002054
2055 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002056 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2058 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002059 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002060
2061 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002062 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002063 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2064 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002065 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002066
2067 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002068 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002069 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2070 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002071 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072
2073 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002074 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002075 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2076 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002077 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078
2079 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002080 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002081 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2082 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002083 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002084
2085 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002086 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002087 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2088 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002089 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002090
2091 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002092 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002093 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2094 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002095 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002096
2097 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002098 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2099 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2100 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2101 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002102 }
2103 }
2104
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002105 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2106 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2107
Petr Krause91f7a12017-12-14 20:57:36 +01002108 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002109 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2110 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2111 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2112 pCreateInfos[i].pColorBlendState,
2113 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2114 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2115
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002116 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002117 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002118 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2119 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2120 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002121 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002122 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2123 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002124
2125 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002126 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002127 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002128 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129
2130 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002131 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2133 pCreateInfos[i].pColorBlendState->logicOpEnable);
2134
2135 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002136 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2138 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002139 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002140 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141
2142 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2143 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2144 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002145 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002146 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2147 ParameterName::IndexVector{i, attachmentIndex}),
2148 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2149
2150 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002151 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002152 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2153 ParameterName::IndexVector{i, attachmentIndex}),
2154 "VkBlendFactor", AllVkBlendFactorEnums,
2155 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002156 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002157
2158 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002159 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002160 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2161 ParameterName::IndexVector{i, attachmentIndex}),
2162 "VkBlendFactor", AllVkBlendFactorEnums,
2163 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002164 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002165
2166 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002167 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002168 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2169 ParameterName::IndexVector{i, attachmentIndex}),
2170 "VkBlendOp", AllVkBlendOpEnums,
2171 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002172 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173
2174 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002175 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002176 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2177 ParameterName::IndexVector{i, attachmentIndex}),
2178 "VkBlendFactor", AllVkBlendFactorEnums,
2179 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002180 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002181
2182 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002183 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002184 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2185 ParameterName::IndexVector{i, attachmentIndex}),
2186 "VkBlendFactor", AllVkBlendFactorEnums,
2187 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002191 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2193 ParameterName::IndexVector{i, attachmentIndex}),
2194 "VkBlendOp", AllVkBlendOpEnums,
2195 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002196 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002197
2198 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002199 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002200 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2201 ParameterName::IndexVector{i, attachmentIndex}),
2202 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2203 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002204 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205 }
2206 }
2207
2208 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002209 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2210 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2211 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2212 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213 }
2214
2215 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2216 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2217 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002218 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002220 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2221 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002222 }
2223 }
2224 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225
Petr Kraus9752aae2017-11-24 03:05:50 +01002226 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2227 if (pCreateInfos[i].basePipelineIndex != -1) {
2228 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002229 skip |=
2230 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2231 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2232 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2233 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002234 }
2235 }
2236
Petr Kraus9752aae2017-11-24 03:05:50 +01002237 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2238 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2240 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2241 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2242 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002244 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002245 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002246 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2247 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2248 "index into the pCreateInfos array, of size %d.",
2249 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002250 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251 }
2252 }
2253
Petr Kraus9752aae2017-11-24 03:05:50 +01002254 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002255 if (!device_extensions.vk_nv_fill_rectangle) {
2256 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2257 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002258 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2259 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2260 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2261 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002262 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2263 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002264 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2265 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2266 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2267 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002268 }
2269 } else {
2270 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2271 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2272 (physical_device_features.fillModeNonSolid == false)) {
2273 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002274 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2275 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2276 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2277 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002278 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002279 }
Petr Kraus299ba622017-11-24 03:09:03 +01002280
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002282 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002283 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2284 "The line width state is static (pCreateInfos[%" PRIu32
2285 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2286 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2287 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2288 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002289 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291 }
2292 }
2293
2294 return skip;
2295}
2296
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002297bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2298 uint32_t createInfoCount,
2299 const VkComputePipelineCreateInfo *pCreateInfos,
2300 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002301 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002302 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002304 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002306 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002307 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2308 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002309 skip |=
2310 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2311 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2312 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2313 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002314 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002315
2316 // Make sure compute stage is selected
2317 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002318 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2319 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2320 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002321 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002322 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002323 return skip;
2324}
2325
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002326bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002327 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002328 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329
2330 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002331 const auto &features = physical_device_features;
2332 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002333
John Zulauf71968502017-10-26 13:51:15 -06002334 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2335 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002336 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2337 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2338 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2339 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002340 }
2341
2342 // Anistropy cannot be enabled in sampler unless enabled as a feature
2343 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002344 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2345 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2346 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002347 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002348 }
John Zulauf71968502017-10-26 13:51:15 -06002349
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002350 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2351 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002352 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2353 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2354 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2355 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002356 }
2357 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2359 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2360 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2361 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002362 }
2363 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002364 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2365 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2366 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2367 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002368 }
2369 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2370 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2371 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2372 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002373 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2374 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2375 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2376 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2377 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2378 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002379 }
2380 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002381 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2382 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2383 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002384 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002385 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002386 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2387 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2388 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002389 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002390 }
2391
2392 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2393 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002394 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2395 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 }
2397
2398 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2399 // valid VkBorderColor value
2400 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2401 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2402 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002403 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2404 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002405 }
2406
2407 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2408 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002409 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002410 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2411 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2412 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002413 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2415 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2416 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417 }
John Zulauf275805c2017-10-26 15:34:49 -06002418
2419 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002420 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002421 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2422 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002423 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2424 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2425 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002426 }
2427 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002428
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002429 // Check for valid Lod range
2430 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002431 skip |=
2432 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2433 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002434 }
2435
2436 // Check mipLodBias to device limit
2437 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002438 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2439 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2440 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002441 }
2442
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002443 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2444 if (sampler_conversion != nullptr) {
2445 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2446 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2447 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2448 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002449 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002450 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002451 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2452 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2453 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2454 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2455 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2456 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2457 }
2458 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459 }
2460
2461 return skip;
2462}
2463
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002464bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2465 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2466 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002467 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002469
2470 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2471 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2472 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2473 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002474 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2475 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2476 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2477 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2478 ++descriptor_index) {
2479 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002480 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002481 "vkCreateDescriptorSetLayout: required parameter "
2482 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2483 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485 }
2486 }
2487
2488 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2489 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2490 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002491 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2492 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2493 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2494 "values.",
2495 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002496 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002497
2498 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2499 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2500 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2501 skip |=
2502 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2503 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2504 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2505 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2506 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2507 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508 }
2509 }
2510 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002511 return skip;
2512}
2513
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002514bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2515 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002516 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2518 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2519 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002520 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2521 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522}
2523
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002524bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2525 const VkWriteDescriptorSet *pDescriptorWrites,
2526 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002527 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002528
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529 if (pDescriptorWrites != NULL) {
2530 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2531 // descriptorCount must be greater than 0
2532 if (pDescriptorWrites[i].descriptorCount == 0) {
2533 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002534 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2535 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002536 }
2537
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002538 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2539 if (validateDstSet) {
2540 // dstSet must be a valid VkDescriptorSet handle
2541 skip |= validate_required_handle(vkCallingFunction,
2542 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2543 pDescriptorWrites[i].dstSet);
2544 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545
2546 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2547 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2548 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2549 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2550 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2551 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2552 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2553 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2554 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2556 "%s(): if pDescriptorWrites[%d].descriptorType is "
2557 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2558 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2559 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2560 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2562 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2563 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2564 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2565 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2566 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002567 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2569 ParameterName::IndexVector{i, descriptor_index}),
2570 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002571 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2573 ParameterName::IndexVector{i, descriptor_index}),
2574 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002575 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 }
2577 }
2578 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2579 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2580 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2581 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2582 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2583 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2584 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2585 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002586 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2587 "%s(): if pDescriptorWrites[%d].descriptorType is "
2588 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2589 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2590 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2591 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002592 } else {
2593 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002594 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002595 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2596 ParameterName::IndexVector{i, descriptorIndex}),
2597 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2598 }
2599 }
2600 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2601 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2602 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2603 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2604 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2606 "%s(): if pDescriptorWrites[%d].descriptorType is "
2607 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2608 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2609 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 } else {
2611 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2612 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002613 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2615 ParameterName::IndexVector{i, descriptor_index}),
2616 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2617 }
2618 }
2619 }
2620
2621 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2622 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002623 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002624 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2625 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2626 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002627 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002628 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2629 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2630 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2631 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002632 }
2633 }
2634 }
2635 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2636 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002637 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2639 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2640 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002641 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002642 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2643 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2644 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2645 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 }
2647 }
2648 }
2649 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002650 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2651 // or VkWriteDescriptorSetInlineUniformBlockEX
2652 if (pDescriptorWrites[i].pNext) {
2653 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2654 const auto *pNext_struct =
2655 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2656 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2657 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2658 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2659 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2660 "accelerationStructureCount %d member equals descriptorCount %d.",
2661 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2662 pDescriptorWrites[i].descriptorCount);
2663 }
2664 // further checks only if we have right structtype
2665 if (pNext_struct) {
2666 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2667 skip |= LogError(
2668 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2669 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2670 ".",
2671 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2672 }
2673 if (pNext_struct->accelerationStructureCount == 0) {
2674 skip |= LogError(
2675 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2676 "%s(): accelerationStructureCount must be greater than 0 .");
2677 }
2678 }
2679 }
2680 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002681 }
2682 }
2683 return skip;
2684}
2685
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002686bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2687 const VkWriteDescriptorSet *pDescriptorWrites,
2688 uint32_t descriptorCopyCount,
2689 const VkCopyDescriptorSet *pDescriptorCopies) const {
2690 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2691}
2692
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002693bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002694 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002695 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002696 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2697}
2698
2699bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002700 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002701 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002702 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2703}
2704
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002705bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2706 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002707 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002709
2710 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2711 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2712 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002713 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2714 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715 return skip;
2716}
2717
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002718bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002719 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002720 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002721
2722 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2723 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2725
Petr Krause7bb9e82019-08-11 21:34:43 +02002726 // Implicit VUs
2727 // validate only sType here; pointer has to be validated in core_validation
2728 const bool kNotRequired = false;
2729 const char *kNoVUID = nullptr;
2730 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2731 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2732 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733
Petr Krause7bb9e82019-08-11 21:34:43 +02002734 if (pInfo) {
2735 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2736 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2737 skip |= validate_struct_pnext(
2738 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2739 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002740 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2741 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742
Petr Krause7bb9e82019-08-11 21:34:43 +02002743 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744
Petr Krause7bb9e82019-08-11 21:34:43 +02002745 // Explicit VUs
2746 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002747 skip |= LogError(
2748 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002749 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2750 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002751 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002752
2753 if (physical_device_features.inheritedQueries) {
2754 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002755 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002756 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002757 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002758 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002759 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002760 }
2761
2762 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002763 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002764 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002765 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002766 } else { // !pipelineStatisticsQuery
2767 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2768 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769 }
Petr Kraus139757b2019-08-15 17:19:33 +02002770
2771 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2772 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002773 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002774 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2775 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002776 skip |= LogError(
2777 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002778 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2779 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2780 }
2781 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 }
2783
2784 return skip;
2785}
2786
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002787bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002788 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002789 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002791 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002792 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2794 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2795 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002796 }
2797 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2799 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2800 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002801 }
2802 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002803 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002804 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002805 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2806 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2807 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2808 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 }
2810 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002811
2812 if (pViewports) {
2813 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2814 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002815 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002816 skip |= manual_PreCallValidateViewport(
2817 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002818 }
2819 }
2820
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002821 return skip;
2822}
2823
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002824bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002825 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002826 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002828 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002829 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002830 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2831 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2832 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002833 }
2834 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2836 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2837 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002838 }
2839 } else { // multiViewport enabled
2840 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002841 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2843 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2844 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2845 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 }
2847 }
2848
Petr Kraus6260f0a2018-02-27 21:15:55 +01002849 if (pScissors) {
2850 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2851 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852
Petr Kraus6260f0a2018-02-27 21:15:55 +01002853 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002854 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2855 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2856 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002857 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858
Petr Kraus6260f0a2018-02-27 21:15:55 +01002859 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2861 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2862 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002863 }
2864
2865 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2866 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002867 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2868 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2869 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2870 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002871 }
2872
2873 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2874 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002875 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2876 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2877 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2878 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002879 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002880 }
2881 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002882
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002883 return skip;
2884}
2885
Jeff Bolz5c801d12019-10-09 10:38:45 -05002886bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002887 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002888
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002889 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002890 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2891 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002892 }
2893
2894 return skip;
2895}
2896
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002897bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002898 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 if (vertexCount == 0) {
2901 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2902 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002903 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 }
2905
2906 if (instanceCount == 0) {
2907 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2908 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002909 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910 }
2911 return skip;
2912}
2913
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002914bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002915 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002917
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002918 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002919 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2920 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002921 }
2922 return skip;
2923}
2924
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002925bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002926 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002929 skip |=
2930 LogError(device, kVUID_PVError_DeviceFeature,
2931 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 }
2933 return skip;
2934}
2935
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002936bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2937 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002938 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002939 bool skip = false;
2940 for (uint32_t rect = 0; rect < rectCount; rect++) {
2941 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002942 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2943 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002944 }
sfricke-samsung10867682020-04-25 02:20:39 -07002945 if (pRects[rect].rect.extent.width == 0) {
2946 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
2947 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
2948 }
2949 if (pRects[rect].rect.extent.height == 0) {
2950 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
2951 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
2952 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002953 }
2954 return skip;
2955}
2956
Andrew Fobel3abeb992020-01-20 16:33:22 -05002957bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2958 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2959 VkImageFormatProperties2 *pImageFormatProperties,
2960 const char *apiName) const {
2961 bool skip = false;
2962
2963 if (pImageFormatInfo != nullptr) {
2964 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2965 if (image_stencil_struct != nullptr) {
2966 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2967 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2968 // No flags other than the legal attachment bits may be set
2969 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2970 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002971 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2972 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2973 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2974 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2975 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002976 }
2977 }
2978 }
2979 }
2980
2981 return skip;
2982}
2983
2984bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2985 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2986 VkImageFormatProperties2 *pImageFormatProperties) const {
2987 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2988 "vkGetPhysicalDeviceImageFormatProperties2");
2989}
2990
2991bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2992 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2993 VkImageFormatProperties2 *pImageFormatProperties) const {
2994 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2995 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2996}
2997
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002998bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2999 VkImageLayout srcImageLayout, VkImage dstImage,
3000 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003001 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003
Dave Houltonf5217612018-02-02 16:18:52 -07003004 VkImageAspectFlags legal_aspect_flags =
3005 VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003006 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003007 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3008 }
3009
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003011 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003012 skip |= LogError(
3013 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003014 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003015 }
Dave Houltonf5217612018-02-02 16:18:52 -07003016 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003017 skip |= LogError(
3018 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003019 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020 }
3021 }
3022 return skip;
3023}
3024
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003025bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3026 VkImageLayout srcImageLayout, VkImage dstImage,
3027 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003028 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003029 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030
Dave Houltonf5217612018-02-02 16:18:52 -07003031 VkImageAspectFlags legal_aspect_flags =
3032 VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003033 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003034 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3035 }
3036
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003038 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003039 skip |= LogError(
3040 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3042 }
Dave Houltonf5217612018-02-02 16:18:52 -07003043 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003044 skip |= LogError(
3045 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003046 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3047 }
3048 }
3049 return skip;
3050}
3051
sfricke-samsung3999ef62020-02-09 17:05:59 -08003052bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3053 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3054 bool skip = false;
3055
3056 if (pRegions != nullptr) {
3057 for (uint32_t i = 0; i < regionCount; i++) {
3058 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003059 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3060 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003061 }
3062 }
3063 }
3064 return skip;
3065}
3066
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003067bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3068 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003069 uint32_t regionCount,
3070 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072
Dave Houltonf5217612018-02-02 16:18:52 -07003073 VkImageAspectFlags legal_aspect_flags =
3074 VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003075 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003076 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3077 }
3078
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003079 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003080 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003081 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3082 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3083 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003084 }
3085 }
3086 return skip;
3087}
3088
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003089bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3090 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003091 uint32_t regionCount,
3092 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003094
Dave Houltonf5217612018-02-02 16:18:52 -07003095 VkImageAspectFlags legal_aspect_flags =
3096 VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003097 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003098 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3099 }
3100
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003101 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003102 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003103 skip |= LogError(
3104 device, kVUID_PVError_UnrecognizedValue,
3105 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3106 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 }
3108 }
3109 return skip;
3110}
3111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003112bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003113 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3114 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003116
3117 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003118 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3119 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3120 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 }
3122
3123 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003124 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3125 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3126 "), must be greater than zero and less than or equal to 65536.",
3127 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003129 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3130 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3131 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 }
3133 return skip;
3134}
3135
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003136bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003137 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139
3140 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3142 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3143 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 }
3145
3146 if (size != VK_WHOLE_SIZE) {
3147 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003148 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003149 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3150 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003151 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003152 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3153 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003154 }
3155 }
3156 return skip;
3157}
3158
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003159bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003160 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003161 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003162 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163
3164 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3166 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3167 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3168 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003169 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3170 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3171 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003172 }
3173
3174 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3175 // queueFamilyIndexCount uint32_t values
3176 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003177 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3178 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3179 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3180 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003181 }
3182 }
3183
Dave Houlton413a6782018-05-22 13:01:54 -06003184 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003185 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186 }
3187
3188 return skip;
3189}
3190
Jeff Bolz5c801d12019-10-09 10:38:45 -05003191bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193
3194 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003195 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3196 if (present_regions) {
3197 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003198 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003199 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3200 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003201 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3202 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3203 "extension swapchainCount is %i. These values must be equal.",
3204 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003205 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003206 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003207 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3208 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003209 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3210 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3211 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003212 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003213 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003214 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003215 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003216 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 }
3218 }
3219
3220 return skip;
3221}
3222
3223#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003224bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3225 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3226 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003227 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 bool skip = false;
3229
3230 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003231 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3232 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 }
3234
3235 return skip;
3236}
3237#endif // VK_USE_PLATFORM_WIN32_KHR
3238
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003239bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003240 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003241 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003242 bool skip = false;
3243
3244 if (pCreateInfo) {
3245 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003246 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3247 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003248 }
3249
3250 if (pCreateInfo->pPoolSizes) {
3251 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3252 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003253 skip |= LogError(
3254 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003255 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003256 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003257 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3258 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3260 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3261 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3262 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3263 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003264 }
Petr Krausc8655be2017-09-27 18:56:51 +02003265 }
3266 }
3267 }
3268
3269 return skip;
3270}
3271
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003272bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003273 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003274 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003275
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003276 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003277 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003278 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3279 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3280 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003281 }
3282
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003283 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003284 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3286 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3287 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003288 }
3289
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003290 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003291 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003292 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3293 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3294 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003295 }
3296
3297 return skip;
3298}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003299
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003300bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003301 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003302 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003303
3304 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3306 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003307 }
3308 return skip;
3309}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003310
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003311bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3312 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003313 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003314 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003315
3316 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003317 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003318 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003319 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3320 "vkCmdDispatch(): baseGroupX (%" PRIu32
3321 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3322 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003323 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003324 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3325 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3326 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3327 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003328 }
3329
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003330 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003331 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003332 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3333 "vkCmdDispatch(): baseGroupY (%" PRIu32
3334 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3335 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003336 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003337 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3338 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3339 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3340 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003341 }
3342
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003343 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003344 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003345 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3346 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3347 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3348 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003349 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003350 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3351 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3352 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3353 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003354 }
3355
3356 return skip;
3357}
3358
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003359bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3360 VkPipelineBindPoint pipelineBindPoint,
3361 VkPipelineLayout layout, uint32_t set,
3362 uint32_t descriptorWriteCount,
3363 const VkWriteDescriptorSet *pDescriptorWrites) const {
3364 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3365}
3366
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003367bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3368 uint32_t firstExclusiveScissor,
3369 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003370 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003371 bool skip = false;
3372
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003373 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003374 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003375 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003376 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3377 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3378 ") is not 0.",
3379 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003380 }
3381 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003382 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003383 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3384 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3385 ") is not 1.",
3386 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003387 }
3388 } else { // multiViewport enabled
3389 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003390 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003391 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3392 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3393 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3394 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003395 }
3396 }
3397
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003398 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003399 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3400 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3401 ") must be less than maxViewports (=%" PRIu32 ").",
3402 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003403 }
3404
3405 if (pExclusiveScissors) {
3406 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3407 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3408
3409 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003410 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3411 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3412 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003413 }
3414
3415 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003416 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3417 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3418 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003419 }
3420
3421 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3422 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003423 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3424 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3425 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3426 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003427 }
3428
3429 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3430 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003431 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3432 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3433 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3434 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003435 }
3436 }
3437 }
3438
3439 return skip;
3440}
3441
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003442bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3443 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003444 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003445 bool skip = false;
3446 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3448 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3449 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003450 } else {
3451 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3452 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003453 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3454 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3455 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3456 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003457 }
3458 }
3459
3460 return skip;
3461}
3462
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003463bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3464 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003465 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003466 bool skip = false;
3467
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003468 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003469 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003470 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003471 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3472 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3473 ") is not 0.",
3474 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003475 }
3476 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003477 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003478 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3479 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3480 ") is not 1.",
3481 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003482 }
3483 }
3484
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003485 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3487 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3488 ") must be less than maxViewports (=%" PRIu32 ").",
3489 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003490 }
3491
3492 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003493 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003494 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3495 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3496 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3497 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003498 }
3499
3500 return skip;
3501}
3502
Jeff Bolz5c801d12019-10-09 10:38:45 -05003503bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3504 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3505 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003506 bool skip = false;
3507
Dave Houlton142c4cb2018-10-17 15:04:41 -06003508 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3510 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3511 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003512 }
3513
3514 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003515 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003516 }
3517
3518 return skip;
3519}
3520
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003521bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003522 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003523 bool skip = false;
3524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003525 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(
3527 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003528 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3529 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003530 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003531 }
3532
3533 return skip;
3534}
3535
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003536bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3537 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003538 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003539 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003540 static const int condition_multiples = 0b0011;
3541 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003542 skip |= LogError(
3543 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003544 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003545 }
Lockee1c22882019-06-10 16:02:54 -06003546 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003547 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3548 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3549 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3550 stride);
Lockee1c22882019-06-10 16:02:54 -06003551 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003552 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003553 skip |= LogError(
3554 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3555 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003556 }
3557
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003558 return skip;
3559}
3560
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003561bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3562 VkDeviceSize offset, VkBuffer countBuffer,
3563 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003564 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003565 bool skip = false;
3566
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003567 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003568 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3569 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3570 "), is not a multiple of 4.",
3571 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003572 }
3573
3574 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003575 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3576 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3577 "), is not a multiple of 4.",
3578 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003579 }
3580
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003581 return skip;
3582}
3583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003584bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003585 const VkAllocationCallbacks *pAllocator,
3586 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003587 bool skip = false;
3588
3589 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3590 if (pCreateInfo != nullptr) {
3591 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3592 // VkQueryPipelineStatisticFlagBits values
3593 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3594 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003595 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3596 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3597 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3598 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003599 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003600 if (pCreateInfo->queryCount == 0) {
3601 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3602 "vkCreateQueryPool(): queryCount must be greater than zero.");
3603 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003604 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003605 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606}
3607
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003608bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3609 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003610 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003611 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3612 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003613}
3614
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003615void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003616 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3617 VkResult result) {
3618 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003619 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620}
3621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003622void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003623 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3624 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003625 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003626 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003627 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003628}
3629
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003630void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3631 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003632 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003633 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003634 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003635}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003636
3637bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003638 const VkAllocationCallbacks *pAllocator,
3639 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003640 bool skip = false;
3641
3642 if (pAllocateInfo) {
3643 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3644 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3646 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003647 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003648
3649 VkMemoryAllocateFlags flags = 0;
3650 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3651 if (flags_info) {
3652 flags = flags_info->flags;
3653 }
3654
3655 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3656 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3657 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003658 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3659 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3660 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003661 }
3662
3663#ifdef VK_USE_PLATFORM_WIN32_KHR
3664 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3665#endif
3666 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3667 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3668#ifdef VK_USE_PLATFORM_ANDROID_KHR
3669 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3670#endif
3671
3672 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003673 skip |= LogError(
3674 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003675 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3676 }
3677 if (
3678#ifdef VK_USE_PLATFORM_WIN32_KHR
3679 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3680#endif
3681 (import_memory_fd && import_memory_fd->handleType) ||
3682#ifdef VK_USE_PLATFORM_ANDROID_KHR
3683 (import_memory_ahb && import_memory_ahb->buffer) ||
3684#endif
3685 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003686 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3687 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003688 }
3689 }
3690
3691 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003692 VkBool32 capture_replay = false;
3693 VkBool32 buffer_device_address = false;
3694 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3695 if (vulkan_12_features) {
3696 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3697 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3698 } else {
3699 const auto *bda_features =
3700 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3701 if (bda_features) {
3702 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3703 buffer_device_address = bda_features->bufferDeviceAddress;
3704 }
3705 }
3706 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003707 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3708 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3709 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003710 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003711 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003712 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3713 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003714 }
3715 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003716 }
3717 return skip;
3718}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003719
Jason Macnak192fa0e2019-07-26 15:07:16 -07003720bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003721 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003722 bool skip = false;
3723
3724 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3725 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3726 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003727 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003728 } else {
3729 uint32_t vertex_component_size = 0;
3730 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3731 vertex_component_size = 4;
3732 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3733 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3734 vertex_component_size = 2;
3735 }
3736 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003737 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003738 }
3739 }
3740
3741 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3742 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003743 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003744 } else {
3745 uint32_t index_element_size = 0;
3746 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3747 index_element_size = 4;
3748 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3749 index_element_size = 2;
3750 }
3751 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003752 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003753 }
3754 }
3755 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3756 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003758 }
3759 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003760 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003761 }
3762 }
3763
3764 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003765 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003766 }
3767
3768 return skip;
3769}
3770
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3772 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003773 bool skip = false;
3774
3775 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003777 }
3778 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003779 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003780 }
3781
3782 return skip;
3783}
3784
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003785bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3786 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003787 bool skip = false;
3788 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003789 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003790 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003791 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003792 }
3793 return skip;
3794}
3795
3796bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003797 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003798 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003799 bool skip = false;
3800 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3802 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3803 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003804 }
3805 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003806 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3807 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3808 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003809 }
3810 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3811 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003812 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3813 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3814 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV bit set.");
Jason Macnak5c954952019-07-09 15:46:12 -07003815 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003816 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003817 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3818 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3819 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003820 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003821 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3823 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3824 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003825 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003826 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003827 uint64_t total_triangle_count = 0;
3828 for (uint32_t i = 0; i < info.geometryCount; i++) {
3829 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003830
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003831 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003832
Jason Macnak5c954952019-07-09 15:46:12 -07003833 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3834 continue;
3835 }
3836 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3837 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003838 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003839 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3840 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3841 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003842 }
3843 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003844 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3845 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3846 for (uint32_t i = 1; i < info.geometryCount; i++) {
3847 const VkGeometryNV &geometry = info.pGeometries[i];
3848 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003849 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003850 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3851 "info.pGeometries[0].geometryType.",
3852 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003853 }
3854 }
3855 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003856 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3857 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3858 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3859 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3860 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3861 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3862 }
3863 }
3864 skip |=
3865 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3866 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003867 return skip;
3868}
3869
Ricardo Garciaa4935972019-02-21 17:43:18 +01003870bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3871 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003872 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003873 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003874 if (pCreateInfo) {
3875 if ((pCreateInfo->compactedSize != 0) &&
3876 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003877 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3878 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3879 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3880 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003881 }
Jason Macnak5c954952019-07-09 15:46:12 -07003882
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003883 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003884 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003885 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003886 return skip;
3887}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003888
Jeff Bolz5c801d12019-10-09 10:38:45 -05003889bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3890 const VkAccelerationStructureInfoNV *pInfo,
3891 VkBuffer instanceData, VkDeviceSize instanceOffset,
3892 VkBool32 update, VkAccelerationStructureNV dst,
3893 VkAccelerationStructureNV src, VkBuffer scratch,
3894 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003895 bool skip = false;
3896
3897 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003898 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003899 }
3900
3901 return skip;
3902}
3903
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003904bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
3905 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3906 VkAccelerationStructureKHR *pAccelerationStructure) const {
3907 bool skip = false;
3908
3909 if (pCreateInfo) {
3910 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
3911 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3912 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3913 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
3914 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
3915 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3916 i);
3917 }
3918 }
3919
3920 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3921 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3922 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
3923 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
3924 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3925 i);
3926 }
3927 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003928 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
3929 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
3930 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
3931 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
3932 skip |= LogError(
3933 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
3934 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
3935 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
3936 }
3937 }
3938 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
3939 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
3940 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
3941 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3942 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
3943 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
3944 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
3945 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
3946 }
3947 }
3948 }
3949
3950 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
3951 pCreateInfo->maxGeometryCount != 1) {
3952 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
3953 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3954 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003955 }
3956
3957 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
3958 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
3959 skip |= LogError(
3960 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
3961 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
3962 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
3963 }
3964
3965 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
3966 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
3967 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
3968 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
3969 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
3970 }
3971
3972 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
3973 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
3974 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
3975 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
3976 if (geometry_type != first_geometry_type) {
3977 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
3978 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
3979 "pGeometryInfos[0].geometryType.",
3980 i);
3981 }
3982 }
3983 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003984 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
3985 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
3986 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
3987 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
3988 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
3989 "maxGeometryCount %d.",
3990 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
3991 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003992 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003993 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
3994 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
3995 if (pCreateInfo->deviceAddress != 0) {
3996 skip |=
3997 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
3998 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
3999 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4000 }
4001 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004002 return skip;
4003}
4004
Jason Macnak5c954952019-07-09 15:46:12 -07004005bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4006 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004007 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004008 bool skip = false;
4009 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004010 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4011 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004012 }
4013 return skip;
4014}
4015
Peter Chen85366392019-05-14 15:20:11 -04004016bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4017 uint32_t createInfoCount,
4018 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4019 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004020 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004021 bool skip = false;
4022
4023 for (uint32_t i = 0; i < createInfoCount; i++) {
4024 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4025 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004026 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4027 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4028 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4029 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4030 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004031 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004032
4033 const auto *pipeline_cache_contol_features =
4034 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4035 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4036 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4037 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4038 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4039 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4040 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4041 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4042 }
4043 }
4044
sourav parmarf4a78252020-04-10 13:04:21 -07004045 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4046 skip |=
4047 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4048 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4049 }
4050 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4051 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4052 skip |=
4053 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4054 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4055 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4056 }
4057 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4058 if (pCreateInfos[i].basePipelineIndex != -1) {
4059 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4060 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4061 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4062 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4063 "and pCreateInfos->basePipelineIndex is not -1.");
4064 }
4065 }
4066 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4067 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4068 skip |=
4069 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4070 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4071 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4072 "commands pCreateInfos parameter.");
4073 }
4074 } else {
4075 if (pCreateInfos[i].basePipelineIndex != -1) {
4076 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4077 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4078 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4079 }
4080 }
4081 }
4082 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4083 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4084 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4085 }
4086 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4087 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4088 "vkCreateRayTracingPipelinesNV: flags must not include "
4089 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4090 }
4091 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4092 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4093 "vkCreateRayTracingPipelinesNV: flags must not include "
4094 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4095 }
4096 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4097 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4098 "vkCreateRayTracingPipelinesNV: flags must not include "
4099 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4100 }
4101 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4102 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4103 "vkCreateRayTracingPipelinesNV: flags must not include "
4104 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4105 }
4106 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4107 skip |= LogError(
4108 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4109 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4110 }
4111 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4112 skip |= LogError(
4113 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4114 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4115 }
Peter Chen85366392019-05-14 15:20:11 -04004116 }
4117
4118 return skip;
4119}
4120
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004121bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4122 uint32_t createInfoCount,
4123 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4124 const VkAllocationCallbacks *pAllocator,
4125 VkPipeline *pPipelines) const {
4126 bool skip = false;
4127
4128 for (uint32_t i = 0; i < createInfoCount; i++) {
4129 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4130 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4131 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4132 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4133 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4134 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4135 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4136 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004137 const auto *pipeline_cache_contol_features =
4138 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4139 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4140 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4141 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4142 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4143 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4144 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4145 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4146 }
4147 }
4148 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4149 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4150 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4151 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4152 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4153 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4154 }
4155 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4156 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4157 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4158 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4159 }
4160 }
4161
sourav parmarf4a78252020-04-10 13:04:21 -07004162 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4163 skip |=
4164 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4165 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4166 }
4167 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4168 if (pCreateInfos[i].pLibraryInterface == NULL)
4169 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4170 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4171 }
4172 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4173 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4174 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4175 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4176 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4177 skip |= LogError(
4178 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4179 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4180 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4181 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4182 "must not be VK_SHADER_UNUSED_KHR");
4183 }
4184 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4185 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4186 skip |= LogError(
4187 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4188 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4189 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4190 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4191 "element must not be VK_SHADER_UNUSED_KHR");
4192 }
4193 }
4194 }
4195 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4196 if (pCreateInfos[i].basePipelineIndex != -1) {
4197 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4198 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4199 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4200 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4201 "and pCreateInfos->basePipelineIndex is not -1.");
4202 }
4203 }
4204 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4205 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4206 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4207 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4208 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4209 "commands pCreateInfos parameter %d.",
4210 pCreateInfos[i].basePipelineIndex, createInfoCount);
4211 }
4212 } else {
4213 if (pCreateInfos[i].basePipelineIndex != -1) {
4214 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4215 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4216 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4217 }
4218 }
4219 }
4220 if (pCreateInfos[i].libraries.libraryCount == 0) {
4221 if (pCreateInfos[i].stageCount == 0) {
4222 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4223 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4224 }
4225 if (pCreateInfos[i].groupCount == 0) {
4226 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4227 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4228 }
4229 } else {
4230 if (pCreateInfos[i].pLibraryInterface == NULL) {
4231 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4232 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4233 }
4234 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004235 }
4236
4237 return skip;
4238}
4239
Mike Schuchardt21638df2019-03-16 10:52:02 -07004240#ifdef VK_USE_PLATFORM_WIN32_KHR
4241bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4242 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004243 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004244 bool skip = false;
4245 if (!device_extensions.vk_khr_swapchain)
4246 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4247 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4248 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4249 if (!device_extensions.vk_khr_surface)
4250 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4251 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4252 skip |=
4253 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4254 if (!device_extensions.vk_ext_full_screen_exclusive)
4255 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4256 skip |= validate_struct_type(
4257 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4258 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4259 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4260 if (pSurfaceInfo != NULL) {
4261 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4262 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4263 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4264
4265 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4266 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4267 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4268 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004269 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4270 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004271
4272 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4273 }
4274 return skip;
4275}
4276#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004277
4278bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4279 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004280 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004281 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4282 bool skip = false;
4283 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4284 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4285 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4286 }
4287 return skip;
4288}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004289
4290bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004291 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004292 bool skip = false;
4293
4294 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004295 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4296 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004297 }
4298
4299 return skip;
4300}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004301
4302bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004303 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004304 bool skip = false;
4305
4306 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004307 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4308 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004309 }
4310
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004311 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06004312 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004313 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4314 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004315 }
4316
4317 return skip;
4318}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004319
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004320bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4321 uint32_t bindingCount, const VkBuffer *pBuffers,
4322 const VkDeviceSize *pOffsets) const {
4323 bool skip = false;
4324 if (firstBinding > device_limits.maxVertexInputBindings) {
4325 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4326 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4327 device_limits.maxVertexInputBindings);
4328 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4329 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4330 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4331 "maxVertexInputBindings (%u)",
4332 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4333 }
4334
4335 return skip;
4336}
4337
Mark Lobodzinski84988402019-09-11 15:27:30 -06004338bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004339 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004340 bool skip = false;
4341 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004342 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4343 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004344 }
4345 return skip;
4346}
4347
4348bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004349 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004350 bool skip = false;
4351 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004352 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4353 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004354 }
4355 return skip;
4356}
Petr Kraus3d720392019-11-13 02:52:39 +01004357
4358bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4359 VkSemaphore semaphore, VkFence fence,
4360 uint32_t *pImageIndex) const {
4361 bool skip = false;
4362
4363 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004364 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4365 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004366 }
4367
4368 return skip;
4369}
4370
4371bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4372 uint32_t *pImageIndex) const {
4373 bool skip = false;
4374
4375 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004376 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4377 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004378 }
4379
4380 return skip;
4381}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004382
4383bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4384 uint32_t firstInstance, VkBuffer counterBuffer,
4385 VkDeviceSize counterBufferOffset,
4386 uint32_t counterOffset, uint32_t vertexStride) const {
4387 bool skip = false;
4388
4389 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004390 skip |= LogError(
4391 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004392 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4393 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4394 }
4395
4396 return skip;
4397}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004398
4399bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4400 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4401 const VkAllocationCallbacks *pAllocator,
4402 VkSamplerYcbcrConversion *pYcbcrConversion,
4403 const char *apiName) const {
4404 bool skip = false;
4405
4406 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004407 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004408 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004409 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4410 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004411 }
4412 return skip;
4413}
4414
4415bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4416 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4417 const VkAllocationCallbacks *pAllocator,
4418 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4419 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4420 "vkCreateSamplerYcbcrConversion");
4421}
4422
4423bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4424 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4425 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4426 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4427 "vkCreateSamplerYcbcrConversionKHR");
4428}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004429
4430bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4431 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4432 bool skip = false;
4433 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4434 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4435
4436 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004437 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4438 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4439 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4440 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4441 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004442 }
4443 return skip;
4444}
sourav parmara96ab1a2020-04-25 16:28:23 -07004445
4446bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4447 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4448 bool skip = false;
4449 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4450 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4451 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4452 }
4453 return skip;
4454}
4455
4456bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4457 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4458 bool skip = false;
4459 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4460 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4461 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4462 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4463 }
4464 return skip;
4465}
4466
4467bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4468 const char *api_name) const {
4469 bool skip = false;
4470 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4471 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4472 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4473 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4474 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4475 api_name);
4476 }
4477 return skip;
4478}
4479
4480bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4481 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4482 bool skip = false;
4483 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
4484 return skip;
4485}
4486
4487bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4488 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4489 bool skip = false;
4490 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4491 return skip;
4492}
4493
4494bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
4495 const char *api_name) const {
4496 bool skip = false;
4497 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
4498 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
4499 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4500 }
4501 return skip;
4502}
4503
4504bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4505 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4506 bool skip = false;
4507 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()");
4508 return skip;
4509}
4510bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4511 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4512 bool skip = false;
4513 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()");
4514 return skip;
4515}