blob: f8587d8ccdbd8f4535ab708d402dec49cb0455ae [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
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700238 skip |= LogError(device, kVUID_PVError_InvalidUsage,
239 "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) {
331 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
332 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700333 skip |=
334 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
335 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
336 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
337 "index value.",
338 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600339 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700340 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
341 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
342 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
343 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600344 } else {
345 set.insert(requested_queue_family);
346 }
347
348 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
349 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
350 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
351 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700352 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
353 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
354 "] (=%f) is not between 0 and 1 (inclusive).",
355 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600356 }
357 }
358 }
359 }
360 }
361
362 return skip;
363}
364
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500365bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700366 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700367 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
368 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
369 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600370 }
371
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700372 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600373}
374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700375bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500376 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100377 bool skip = false;
378
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600379 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |=
381 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600382
383 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
384 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
385 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
386 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700387 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
388 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
389 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600390 }
391
392 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
393 // queueFamilyIndexCount uint32_t values
394 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700395 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
396 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
397 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
398 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600399 }
400 }
401
402 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
403 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
404 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
405 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700406 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
407 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
408 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600409 }
410 }
411
412 return skip;
413}
414
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700415bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500416 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600417 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600418
419 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600420 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
421 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
422 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
423 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700424 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
425 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
426 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600427 }
428
429 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
430 // queueFamilyIndexCount uint32_t values
431 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700432 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
433 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
434 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
435 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600436 }
437 }
438
Dave Houlton413a6782018-05-22 13:01:54 -0600439 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700440 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600441 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700442 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600443 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600445
Dave Houlton413a6782018-05-22 13:01:54 -0600446 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700447 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600448 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600450
Dave Houlton130c0212018-01-29 13:39:56 -0700451 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700452 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
453 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700454 skip |= LogError(
455 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600456 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
457 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700458 }
459
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600460 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100461 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
462 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
464 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
465 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466 }
467
468 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100469 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
470 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
472 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
473 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
474 ") are not equal.",
475 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100476 }
477
478 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
480 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
481 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
482 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100483 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 }
485
486 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(
488 device, "VUID-VkImageCreateInfo-imageType-00957",
489 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600490 }
491 }
492
Dave Houlton130c0212018-01-29 13:39:56 -0700493 // 3D image may have only 1 layer
494 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700495 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
496 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700497 }
498
499 // If multi-sample, validate type, usage, tiling and mip levels.
500 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
501 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600502 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700503 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
504 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700505 }
506
507 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
508 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
509 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
510 // At least one of the legal attachment bits must be set
511 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700512 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
513 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700514 }
515 // No flags other than the legal attachment bits may be set
516 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
517 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700518 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
519 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700520 }
521 }
522
Jeff Bolzef40fec2018-09-01 22:04:34 -0500523 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600524 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500525 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600526 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
527 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500528 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600529 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
531 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
532 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600533 }
534
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600535 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700536 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
537 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
538 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600539 }
540
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700541 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700542 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
543 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
544 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100545 }
546
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600547 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
548 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
549 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
550 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
552 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
553 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 }
555
556 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
557 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
558 // Linear tiling is unsupported
559 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700560 skip |= LogError(device, kVUID_PVError_InvalidUsage,
561 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
562 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600563 }
564
565 // Sparse 1D image isn't valid
566 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
568 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570
571 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700572 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700573 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
574 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
575 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600576 }
577
578 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700579 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700580 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
581 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
582 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 }
584
585 // Multi-sample 2D image when device doesn't support it
586 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700587 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700589 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
590 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
591 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700592 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600593 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
595 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
596 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700597 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600598 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
600 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
601 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700602 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600603 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
605 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
606 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600607 }
608 }
609 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500610
Jeff Bolz9af91c52018-09-01 21:53:57 -0500611 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
612 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700613 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
614 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
615 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500616 }
617 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700618 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
619 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
620 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500621 }
622 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
624 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
625 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500626 }
627 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500628
629 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600630 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
632 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
633 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500634 }
635
Dave Houlton142c4cb2018-10-17 15:04:41 -0600636 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
638 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
639 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
640 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500641 }
642
Dave Houlton142c4cb2018-10-17 15:04:41 -0600643 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
645 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
646 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
647 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500648 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600649 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700650 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
651 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
652 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
653 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500654 }
655 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500656
657 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
658 if (image_stencil_struct != nullptr) {
659 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
660 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
661 // No flags other than the legal attachment bits may be set
662 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
663 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700664 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
665 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
666 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
667 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500668 }
669 }
670
671 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
672 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
673 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
674 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
676 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
677 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
678 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500679 }
680
681 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700683 LogError(device, "VUID-VkImageCreateInfo-format-02537",
684 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
685 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
686 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500687 }
688 }
689
690 if (!physical_device_features.shaderStorageImageMultisample &&
691 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
692 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
693 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 LogError(device, "VUID-VkImageCreateInfo-format-02538",
695 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
696 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
697 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500698 }
699
700 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
701 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 skip |= LogError(
703 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500704 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
705 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
706 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
707 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
708 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(
710 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500711 "vkCreateImage(): Depth-stencil image in which usage does not include "
712 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
713 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
714 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
715 }
716
717 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
718 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(
720 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500721 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
722 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
723 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
724 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
725 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(
727 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500728 "vkCreateImage(): Depth-stencil image in which usage does not include "
729 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
730 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
731 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
732 }
733 }
734 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700735
736 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
737 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
738 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
739 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
740 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
741 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700742
743 if (device_extensions.vk_ext_image_drm_format_modifier) {
744 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
745 const auto drm_format_mod_explict =
746 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
747 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
748 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
749 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
750 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
751 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
752 "either VkImageDrmFormatModifierListCreateInfoEXT or "
753 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
754 }
755 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
756 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
757 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
758 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
759 "in the pNext chain");
760 }
761 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500763
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600764 return skip;
765}
766
Jeff Bolz99e3f632020-03-24 22:59:22 -0500767bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
768 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
769 bool skip = false;
770
771 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700772 // Validate feature set if using CUBE_ARRAY
773 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
774 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
775 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
776 "enabling the imageCubeArray feature.");
777 }
778
Jeff Bolz99e3f632020-03-24 22:59:22 -0500779 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
780 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
781 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700782 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500783 pCreateInfo->subresourceRange.layerCount);
784 }
785 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700786 skip |= LogError(
787 device, "VUID-VkImageViewCreateInfo-viewType-02961",
788 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
789 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500790 }
791 }
792 }
793 return skip;
794}
795
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600796bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100798 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100799
800 // Note: for numerical correctness
801 // - float comparisons should expect NaN (comparison always false).
802 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
803
804 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700805 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100806 if (v1_f <= 0.0f) return true;
807
808 float intpart;
809 const float fract = modff(v1_f, &intpart);
810
811 assert(std::numeric_limits<float>::radix == 2);
812 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
813 if (intpart >= u32_max_plus1) return false;
814
815 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
816 if (v1_u32 < v2_u32)
817 return true;
818 else if (v1_u32 == v2_u32 && fract == 0.0f)
819 return true;
820 else
821 return false;
822 };
823
824 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
825 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
826 return (v1_f <= v2_f);
827 };
828
829 // width
830 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700831 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100832
833 if (!(viewport.width > 0.0f)) {
834 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700835 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
836 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100837 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
838 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700839 skip |= LogError(object, "VUID-VkViewport-width-01771",
840 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
841 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100842 } 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 -0700843 skip |= LogWarning(object, kVUID_PVError_NONE,
844 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
845 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
846 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100847 }
848
849 // height
850 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700851 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700852 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100853
854 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
855 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700856 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
857 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100858 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
859 height_healthy = false;
860
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700861 skip |= LogError(object, "VUID-VkViewport-height-01773",
862 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
863 ").",
864 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100865 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
866 height_healthy = false;
867
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogWarning(
869 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600871 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600872 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100873 }
874
875 // x
876 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700877 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100878 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700879 skip |= LogError(object, "VUID-VkViewport-x-01774",
880 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
881 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100882 }
883
884 // x + width
885 if (x_healthy && width_healthy) {
886 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700887 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700888 skip |= LogError(
889 object, "VUID-VkViewport-x-01232",
890 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
891 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
892 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100893 }
894 }
895
896 // y
897 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700898 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100899 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700900 skip |= LogError(object, "VUID-VkViewport-y-01775",
901 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
902 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700903 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100904 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(object, "VUID-VkViewport-y-01776",
906 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
907 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100908 }
909
910 // y + height
911 if (y_healthy && height_healthy) {
912 const float boundary = viewport.y + viewport.height;
913
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700914 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700915 skip |= LogError(object, "VUID-VkViewport-y-01233",
916 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
917 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
918 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700919 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600920 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700921 LogError(object, "VUID-VkViewport-y-01777",
922 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
923 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
924 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100925 }
926 }
927
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700928 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100929 // minDepth
930 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600932
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700933 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
934 "[0.0, 1.0] range.",
935 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100936 }
937
938 // maxDepth
939 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700940 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600941
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700942 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
943 "[0.0, 1.0] range.",
944 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100945 }
946 }
947
948 return skip;
949}
950
Dave Houlton142c4cb2018-10-17 15:04:41 -0600951struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500952 VkShadingRatePaletteEntryNV shadingRate;
953 uint32_t width;
954 uint32_t height;
955};
956
957// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600958static SampleOrderInfo sampleOrderInfos[] = {
959 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
960 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
961 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
962 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
963 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
964 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500965};
966
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500967bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500968 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500969
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500970 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500971 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500972 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500973 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500974 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500975 break;
976 }
977 }
978
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500979 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700980 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
981 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
982 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500983 return skip;
984 }
985
Dave Houlton142c4cb2018-10-17 15:04:41 -0600986 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700987 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700988 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
989 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
990 ") must "
991 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
992 "is set in framebufferNoAttachmentsSampleCounts.",
993 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500994 }
995
Jeff Bolz9af91c52018-09-01 21:53:57 -0500996 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700997 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
998 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
999 ") must "
1000 "be equal to the product of sampleCount (=%" PRIu32
1001 "), the fragment width for shadingRate "
1002 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1003 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001004 }
1005
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001006 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001007 skip |= LogError(
1008 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001009 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1010 ") must "
1011 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001012 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001013 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001014
1015 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001016 // the first width*height*sampleCount bits to all be set. Note: There is no
1017 // guarantee that 64 bits is enough, but practically it's unlikely for an
1018 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001019 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001020 uint64_t sampleLocationsMask = 0;
1021 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1022 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1023 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001024 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1025 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001026 }
1027 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001028 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1029 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001030 }
1031 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001032 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1033 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001034 }
1035 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1036 sampleLocationsMask |= 1ULL << idx;
1037 }
1038
1039 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1040 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001041 skip |= LogError(
1042 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001043 "The array pSampleLocations must contain exactly one entry for "
1044 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001045 }
1046
1047 return skip;
1048}
1049
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001050bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1051 uint32_t createInfoCount,
1052 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1053 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001054 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001055 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001056
1057 if (pCreateInfos != nullptr) {
1058 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001059 bool has_dynamic_viewport = false;
1060 bool has_dynamic_scissor = false;
1061 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001062 bool has_dynamic_depth_bias = false;
1063 bool has_dynamic_blend_constant = false;
1064 bool has_dynamic_depth_bounds = false;
1065 bool has_dynamic_stencil_compare = false;
1066 bool has_dynamic_stencil_write = false;
1067 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001068 bool has_dynamic_viewport_w_scaling_nv = false;
1069 bool has_dynamic_discard_rectangle_ext = false;
1070 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001071 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001072 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001073 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001074 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001075 if (pCreateInfos[i].pDynamicState != nullptr) {
1076 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1077 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1078 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001079 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1080 if (has_dynamic_viewport == true) {
1081 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1082 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1083 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1084 i);
1085 }
1086 has_dynamic_viewport = true;
1087 }
1088 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1089 if (has_dynamic_scissor == true) {
1090 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1091 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1092 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1093 i);
1094 }
1095 has_dynamic_scissor = true;
1096 }
1097 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1098 if (has_dynamic_line_width == true) {
1099 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1100 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1101 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1102 i);
1103 }
1104 has_dynamic_line_width = true;
1105 }
1106 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1107 if (has_dynamic_depth_bias == true) {
1108 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1109 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1110 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1111 i);
1112 }
1113 has_dynamic_depth_bias = true;
1114 }
1115 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1116 if (has_dynamic_blend_constant == true) {
1117 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1118 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1119 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1120 i);
1121 }
1122 has_dynamic_blend_constant = true;
1123 }
1124 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1125 if (has_dynamic_depth_bounds == true) {
1126 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1127 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1128 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1129 i);
1130 }
1131 has_dynamic_depth_bounds = true;
1132 }
1133 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1134 if (has_dynamic_stencil_compare == true) {
1135 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1136 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1137 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1138 i);
1139 }
1140 has_dynamic_stencil_compare = true;
1141 }
1142 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1143 if (has_dynamic_stencil_write == true) {
1144 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1145 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1146 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1147 i);
1148 }
1149 has_dynamic_stencil_write = true;
1150 }
1151 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1152 if (has_dynamic_stencil_reference == true) {
1153 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1154 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1155 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1156 i);
1157 }
1158 has_dynamic_stencil_reference = true;
1159 }
1160 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1161 if (has_dynamic_viewport_w_scaling_nv == true) {
1162 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1163 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1164 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1165 i);
1166 }
1167 has_dynamic_viewport_w_scaling_nv = true;
1168 }
1169 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1170 if (has_dynamic_discard_rectangle_ext == true) {
1171 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1172 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1173 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1174 i);
1175 }
1176 has_dynamic_discard_rectangle_ext = true;
1177 }
1178 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1179 if (has_dynamic_sample_locations_ext == true) {
1180 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1181 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1182 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1183 i);
1184 }
1185 has_dynamic_sample_locations_ext = true;
1186 }
1187 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1188 if (has_dynamic_exclusive_scissor_nv == true) {
1189 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1190 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1191 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1192 i);
1193 }
1194 has_dynamic_exclusive_scissor_nv = true;
1195 }
1196 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1197 if (has_dynamic_shading_rate_palette_nv == true) {
1198 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1199 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1200 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1201 i);
1202 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001203 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001204 }
1205 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1206 if (has_dynamic_viewport_course_sample_order_nv == true) {
1207 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1208 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1209 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1210 i);
1211 }
1212 has_dynamic_viewport_course_sample_order_nv = true;
1213 }
1214 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1215 if (has_dynamic_line_stipple == true) {
1216 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1217 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1218 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1219 i);
1220 }
1221 has_dynamic_line_stipple = true;
1222 }
Petr Kraus299ba622017-11-24 03:09:03 +01001223 }
1224 }
1225
Peter Chen85366392019-05-14 15:20:11 -04001226 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1227 if ((feedback_struct != nullptr) &&
1228 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001229 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1230 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1231 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1232 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1233 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001234 }
1235
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001236 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001237
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001238 // Collect active stages and other information
1239 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001240 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001241 bool has_eval = false;
1242 bool has_control = false;
1243 if (pCreateInfos[i].pStages != nullptr) {
1244 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1245 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1246
1247 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1248 has_control = true;
1249 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1250 has_eval = true;
1251 }
1252
1253 skip |= validate_string(
1254 "vkCreateGraphicsPipelines",
1255 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1256 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1257 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001258 }
1259
1260 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1261 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1262 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1263 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1264 pCreateInfos[i].pTessellationState,
1265 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1266 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1267
1268 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1269 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1270
1271 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1272 "VkPipelineTessellationDomainOriginStateCreateInfo",
1273 pCreateInfos[i].pTessellationState->pNext,
1274 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1275 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001276 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1277 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001278
1279 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1280 pCreateInfos[i].pTessellationState->flags,
1281 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1282 }
1283
1284 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1285 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1286 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1287 pCreateInfos[i].pInputAssemblyState,
1288 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1289 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1290
1291 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1292 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001293 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001294
1295 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1296 pCreateInfos[i].pInputAssemblyState->flags,
1297 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1298
1299 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1300 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1301 pCreateInfos[i].pInputAssemblyState->topology,
1302 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1303
1304 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1305 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1306 }
1307
1308 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001309 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001310
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001311 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001312 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1313 "vkCreateGraphicsPipelines: pararameter "
1314 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1315 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001316 }
1317
1318 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1319 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1320 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1321 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1322 pCreateInfos[i].pVertexInputState->pNext, 1,
1323 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001324 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1325 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001326 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1327 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001328 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001329 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1330 skip |=
1331 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1332 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1333 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1334 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1335 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1336
1337 skip |= validate_array(
1338 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1339 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1340 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1341 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1342
1343 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1344 for (uint32_t vertexBindingDescriptionIndex = 0;
1345 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1346 ++vertexBindingDescriptionIndex) {
1347 skip |= validate_ranged_enum(
1348 "vkCreateGraphicsPipelines",
1349 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1350 AllVkVertexInputRateEnums,
1351 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1352 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1353 }
1354 }
1355
1356 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1357 for (uint32_t vertexAttributeDescriptionIndex = 0;
1358 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1359 ++vertexAttributeDescriptionIndex) {
1360 skip |= validate_ranged_enum(
1361 "vkCreateGraphicsPipelines",
1362 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1363 AllVkFormatEnums,
1364 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1365 "VUID-VkVertexInputAttributeDescription-format-parameter");
1366 }
1367 }
1368
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001369 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001370 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1371 "vkCreateGraphicsPipelines: pararameter "
1372 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1373 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1374 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001375 }
1376
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001377 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001378 skip |=
1379 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1380 "vkCreateGraphicsPipelines: pararameter "
1381 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1382 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1383 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001384 }
1385
1386 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001387 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1388 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001389 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1390 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001391 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1392 "vkCreateGraphicsPipelines: parameter "
1393 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1394 "(%" PRIu32 ") is not distinct.",
1395 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001396 }
1397 vertex_bindings.insert(vertex_bind_desc.binding);
1398
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001399 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001400 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1401 "vkCreateGraphicsPipelines: parameter "
1402 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1403 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1404 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001405 }
1406
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001407 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001408 skip |=
1409 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1410 "vkCreateGraphicsPipelines: parameter "
1411 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1412 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1413 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001414 }
1415 }
1416
Peter Kohautc7d9d392018-07-15 00:34:07 +02001417 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001418 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1419 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001420 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1421 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001422 skip |= LogError(
1423 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001424 "vkCreateGraphicsPipelines: parameter "
1425 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1426 i, d, vertex_attrib_desc.location);
1427 }
1428 attribute_locations.insert(vertex_attrib_desc.location);
1429
1430 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1431 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001432 skip |= LogError(
1433 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001434 "vkCreateGraphicsPipelines: parameter "
1435 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1436 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1437 i, d, vertex_attrib_desc.binding, i);
1438 }
1439
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001440 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001441 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1442 "vkCreateGraphicsPipelines: parameter "
1443 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1444 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1445 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001446 }
1447
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001448 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001449 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1450 "vkCreateGraphicsPipelines: parameter "
1451 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1452 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1453 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001454 }
1455
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001456 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001457 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1458 "vkCreateGraphicsPipelines: parameter "
1459 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1460 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1461 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001462 }
1463 }
1464 }
1465
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001466 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1467 if (has_control && has_eval) {
1468 if (pCreateInfos[i].pTessellationState == nullptr) {
1469 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1470 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1471 "shader stage and a tessellation evaluation shader stage, "
1472 "pCreateInfos[%d].pTessellationState must not be NULL.",
1473 i, i);
1474 } else {
1475 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1476 skip |= validate_struct_pnext(
1477 "vkCreateGraphicsPipelines",
1478 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1479 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1480 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1481 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001482
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001483 skip |= validate_reserved_flags(
1484 "vkCreateGraphicsPipelines",
1485 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1486 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001487
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001488 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1489 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1490 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1491 "vkCreateGraphicsPipelines: invalid parameter "
1492 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1493 "should be >0 and <=%u.",
1494 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1495 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001496 }
1497 }
1498 }
1499
1500 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1501 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1502 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1503 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001504 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1505 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1506 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1507 "].pViewportState (=NULL) is not a valid pointer.",
1508 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001509 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001510 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1511
1512 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1514 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1515 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1516 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001517 }
1518
Petr Krausa6103552017-11-16 21:21:58 +01001519 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1520 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001521 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1522 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001523 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1524 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001525 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001526 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001527 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001528 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001529 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001530 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1531 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001532 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001533 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1534 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001535
1536 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001537 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001538 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001539 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001540
Dave Houlton142c4cb2018-10-17 15:04:41 -06001541 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1542 pCreateInfos[i].pViewportState->pNext);
1543 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1544 pCreateInfos[i].pViewportState->pNext);
1545 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1546 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001547 const auto vp_swizzle_struct =
1548 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001549 const auto vp_w_scaling_struct =
1550 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001551
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001552 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001553 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001554 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1555 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1556 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1557 ") is not 1.",
1558 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001559 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001560
Petr Krausa6103552017-11-16 21:21:58 +01001561 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001562 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1563 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1564 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1565 ") is not 1.",
1566 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001567 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001568
Dave Houlton142c4cb2018-10-17 15:04:41 -06001569 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1570 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001571 skip |= LogError(
1572 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1573 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1574 "disabled, but pCreateInfos[%" PRIu32
1575 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1576 ") is not 1.",
1577 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001578 }
1579
Jeff Bolz9af91c52018-09-01 21:53:57 -05001580 if (shading_rate_image_struct &&
1581 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001582 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1583 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1584 "disabled, but pCreateInfos[%" PRIu32
1585 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1586 ") is neither 0 nor 1.",
1587 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001588 }
1589
Petr Krausa6103552017-11-16 21:21:58 +01001590 } else { // multiViewport enabled
1591 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001592 skip |= LogError(
1593 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001594 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001595 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001596 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1597 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1598 "].pViewportState->viewportCount (=%" PRIu32
1599 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1600 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001601 }
Petr Krausa6103552017-11-16 21:21:58 +01001602
1603 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001604 skip |= LogError(
1605 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001606 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001607 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001608 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1609 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1610 "].pViewportState->scissorCount (=%" PRIu32
1611 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1612 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001613 }
1614 }
1615
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001616 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001617 skip |=
1618 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1619 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1620 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1621 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001622 }
1623
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001624 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001625 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1626 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1627 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1628 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1629 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001630 }
1631
Petr Krausa6103552017-11-16 21:21:58 +01001632 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001633 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1634 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1635 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1636 "].pViewportState->viewportCount (=%" PRIu32 ").",
1637 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001638 }
1639
Dave Houlton142c4cb2018-10-17 15:04:41 -06001640 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001641 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001642 skip |=
1643 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1644 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1645 ") must be zero or identical to pCreateInfos[%" PRIu32
1646 "].pViewportState->viewportCount (=%" PRIu32 ").",
1647 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001648 }
1649
Dave Houlton142c4cb2018-10-17 15:04:41 -06001650 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001651 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001652 skip |= LogError(
1653 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001654 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1655 "] "
1656 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1657 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1658 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001659 }
1660
Petr Krausa6103552017-11-16 21:21:58 +01001661 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001662 skip |= LogError(
1663 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001664 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1665 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001666 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1667 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001668 }
1669
1670 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001671 skip |= LogError(
1672 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001673 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1674 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001675 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1676 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001677 }
1678
Jeff Bolz3e71f782018-08-29 23:15:45 -05001679 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001680 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1681 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001683 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1684 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1685 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1686 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1687 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001688 }
1689
Jeff Bolz9af91c52018-09-01 21:53:57 -05001690 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001691 shading_rate_image_struct->viewportCount > 0 &&
1692 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001693 skip |= LogError(
1694 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001695 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001696 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1697 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001698 i, i);
1699 }
1700
Chris Mayer328d8212018-12-11 14:16:18 +01001701 if (vp_swizzle_struct) {
1702 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001703 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1704 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1705 " does "
1706 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1707 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001708 }
1709 }
1710
Petr Krausb3fcdb42018-01-09 22:09:09 +01001711 // validate the VkViewports
1712 if (!has_dynamic_viewport && viewport_state.pViewports) {
1713 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1714 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001715 const char *fn_name = "vkCreateGraphicsPipelines";
1716 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1717 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1718 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001719 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001720 }
1721 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001722
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001723 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001724 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1725 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1726 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1727 "VK_NV_clip_space_w_scaling extension is not enabled.",
1728 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001729 }
1730
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001731 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001732 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1733 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1734 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1735 "VK_EXT_discard_rectangles extension is not enabled.",
1736 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001737 }
1738
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001739 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001740 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1741 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1742 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1743 "VK_EXT_sample_locations extension is not enabled.",
1744 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001745 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001746
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001747 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001748 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1749 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1750 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1751 "VK_NV_scissor_exclusive extension is not enabled.",
1752 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001753 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001754
1755 if (coarse_sample_order_struct &&
1756 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1757 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001758 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1759 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1760 "] "
1761 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1762 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1763 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001764 }
1765
1766 if (coarse_sample_order_struct) {
1767 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001768 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001769 }
1770 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001771
1772 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1773 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001774 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1775 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1776 "] "
1777 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1778 ") "
1779 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1780 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001781 }
1782 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001783 skip |= LogError(
1784 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001785 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1786 "] "
1787 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1788 i);
1789 }
1790 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001791 }
1792
1793 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001794 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1795 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1796 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1797 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001798 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001799 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1800 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1801 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001802 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001803 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001804 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001805 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001806 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001807 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001808 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001809 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1810 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001811
1812 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001813 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001814 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001815 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001816
1817 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001818 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001819 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1820 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1821
1822 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001823 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001824 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1825 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001826 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001827 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001828
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001829 skip |= validate_flags(
1830 "vkCreateGraphicsPipelines",
1831 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1832 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001833 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001834
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001836 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001837 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1838 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1839
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->alphaToOneEnable", ParameterName::IndexVector{i}),
1843 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1844
1845 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001846 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1847 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1848 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1849 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001850 }
John Zulauf7acac592017-11-06 11:15:53 -07001851 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001852 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001853 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1854 "vkCreateGraphicsPipelines(): parameter "
1855 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1856 i);
John Zulauf7acac592017-11-06 11:15:53 -07001857 }
1858 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1859 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1860 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001861 skip |= LogError(
1862 device,
1863
Dave Houlton413a6782018-05-22 13:01:54 -06001864 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001865 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001866 }
1867 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001868
1869 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1870 pCreateInfos[i].pRasterizationState->pNext);
1871
1872 if (line_state) {
1873 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1874 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1875 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1876 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1878 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1879 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1880 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001881 }
1882 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1883 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001884 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1885 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1886 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1887 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001888 }
1889 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1890 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001891 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1892 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1893 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1894 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001895 }
1896 }
1897 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1898 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1899 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1901 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1902 "range [1,256].",
1903 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001904 }
1905 }
1906 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001907 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001908 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1909 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |=
1911 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1912 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1913 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1914 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001915 }
1916 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1917 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001918 skip |=
1919 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1920 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1921 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1922 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001923 }
1924 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1925 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001926 skip |=
1927 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1928 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1929 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1930 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001931 }
1932 if (line_state->stippledLineEnable) {
1933 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1934 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001935 skip |=
1936 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1937 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1938 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1939 "stippledRectangularLines feature.",
1940 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001941 }
1942 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1943 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001944 skip |=
1945 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1946 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1947 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1948 "stippledBresenhamLines feature.",
1949 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001950 }
1951 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1952 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001953 skip |=
1954 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1955 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1956 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1957 "stippledSmoothLines feature.",
1958 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001959 }
1960 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1961 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001962 skip |=
1963 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1964 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1965 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1966 "stippledRectangularLines and strictLines features.",
1967 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001968 }
1969 }
1970 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971 }
1972
Petr Krause91f7a12017-12-14 20:57:36 +01001973 bool uses_color_attachment = false;
1974 bool uses_depthstencil_attachment = false;
1975 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001976 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001977 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1978 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001979 const auto &subpasses_uses = subpasses_uses_it->second;
1980 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1981 uses_color_attachment = true;
1982 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1983 uses_depthstencil_attachment = true;
1984 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001985 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001986 }
1987
1988 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001990 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001991 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001992 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001993 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994
1995 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001996 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001997 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001998 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001999
2000 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002001 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2003 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2004
2005 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002006 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002007 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2008 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2009
2010 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002011 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2013 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002014 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002015
2016 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002017 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002018 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2019 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2020
2021 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002022 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002023 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2024 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2025
2026 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002027 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2029 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002030 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002031
2032 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002033 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002034 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2035 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002036 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002037
2038 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002039 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002040 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2041 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002042 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002043
2044 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002045 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002046 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2047 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002048 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002049
2050 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002051 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002052 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2053 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002054 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002055
2056 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002057 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002058 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2059 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002060 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002061
2062 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002063 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002064 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2065 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002066 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002067
2068 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002069 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2071 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002072 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002073
2074 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002075 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2076 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2077 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2078 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002079 }
2080 }
2081
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002082 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2083 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2084
Petr Krause91f7a12017-12-14 20:57:36 +01002085 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002086 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2087 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2088 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2089 pCreateInfos[i].pColorBlendState,
2090 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2091 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2092
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002093 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002094 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002095 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2096 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2097 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002098 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002099 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2100 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002101
2102 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002103 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002104 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002105 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002106
2107 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002108 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002109 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2110 pCreateInfos[i].pColorBlendState->logicOpEnable);
2111
2112 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002113 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002114 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2115 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002116 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002117 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002118
2119 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2120 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2121 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002122 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2124 ParameterName::IndexVector{i, attachmentIndex}),
2125 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2126
2127 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002128 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2130 ParameterName::IndexVector{i, attachmentIndex}),
2131 "VkBlendFactor", AllVkBlendFactorEnums,
2132 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002133 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002134
2135 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002136 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2138 ParameterName::IndexVector{i, attachmentIndex}),
2139 "VkBlendFactor", AllVkBlendFactorEnums,
2140 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002141 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002142
2143 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002144 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002145 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2146 ParameterName::IndexVector{i, attachmentIndex}),
2147 "VkBlendOp", AllVkBlendOpEnums,
2148 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002149 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002150
2151 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002152 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002153 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2154 ParameterName::IndexVector{i, attachmentIndex}),
2155 "VkBlendFactor", AllVkBlendFactorEnums,
2156 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002157 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002158
2159 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002160 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002161 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2162 ParameterName::IndexVector{i, attachmentIndex}),
2163 "VkBlendFactor", AllVkBlendFactorEnums,
2164 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002165 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002166
2167 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002168 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002169 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2170 ParameterName::IndexVector{i, attachmentIndex}),
2171 "VkBlendOp", AllVkBlendOpEnums,
2172 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002173 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002174
2175 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002176 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2178 ParameterName::IndexVector{i, attachmentIndex}),
2179 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2180 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002181 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002182 }
2183 }
2184
2185 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002186 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2187 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2188 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2189 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002190 }
2191
2192 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2193 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2194 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002195 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002196 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002197 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2198 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002199 }
2200 }
2201 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002202
Petr Kraus9752aae2017-11-24 03:05:50 +01002203 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2204 if (pCreateInfos[i].basePipelineIndex != -1) {
2205 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002206 skip |=
2207 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2208 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2209 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2210 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211 }
2212 }
2213
Petr Kraus9752aae2017-11-24 03:05:50 +01002214 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2215 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002216 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2217 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2218 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2219 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002220 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002221 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002222 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002223 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2224 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2225 "index into the pCreateInfos array, of size %d.",
2226 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002227 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002228 }
2229 }
2230
Petr Kraus9752aae2017-11-24 03:05:50 +01002231 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002232 if (!device_extensions.vk_nv_fill_rectangle) {
2233 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2234 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002235 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2236 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2237 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2238 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002239 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2240 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002241 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2242 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2243 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2244 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002245 }
2246 } else {
2247 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2248 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2249 (physical_device_features.fillModeNonSolid == false)) {
2250 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002251 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2252 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2253 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2254 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002255 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 }
Petr Kraus299ba622017-11-24 03:09:03 +01002257
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002258 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002259 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002260 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2261 "The line width state is static (pCreateInfos[%" PRIu32
2262 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2263 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2264 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2265 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002266 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002267 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002268 }
2269 }
2270
2271 return skip;
2272}
2273
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002274bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2275 uint32_t createInfoCount,
2276 const VkComputePipelineCreateInfo *pCreateInfos,
2277 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002278 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002279 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002280 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002283 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002284 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2285 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002286 skip |=
2287 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2288 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2289 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2290 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002291 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002292
2293 // Make sure compute stage is selected
2294 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002295 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2296 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2297 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002298 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002299 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300 return skip;
2301}
2302
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002303bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002304 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306
2307 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002308 const auto &features = physical_device_features;
2309 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002310
John Zulauf71968502017-10-26 13:51:15 -06002311 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2312 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002313 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2314 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2315 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2316 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002317 }
2318
2319 // Anistropy cannot be enabled in sampler unless enabled as a feature
2320 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002321 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2322 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2323 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002324 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002325 }
John Zulauf71968502017-10-26 13:51:15 -06002326
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002327 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2328 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2330 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2331 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2332 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002333 }
2334 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002335 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2336 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2337 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2338 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002339 }
2340 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002341 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2342 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2343 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2344 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002345 }
2346 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2347 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2348 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2349 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002350 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2351 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2352 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2353 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2354 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2355 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002356 }
2357 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2359 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2360 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002361 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002362 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002363 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2364 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2365 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002366 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367 }
2368
2369 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2370 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002371 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2372 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002373 }
2374
2375 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2376 // valid VkBorderColor value
2377 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2378 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2379 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002380 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2381 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002382 }
2383
2384 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2385 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002386 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002387 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2388 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2389 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002390 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2392 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2393 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002394 }
John Zulauf275805c2017-10-26 15:34:49 -06002395
2396 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002397 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002398 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2399 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2401 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2402 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002403 }
2404 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002405
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002406 // Check for valid Lod range
2407 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002408 skip |=
2409 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2410 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002411 }
2412
2413 // Check mipLodBias to device limit
2414 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002415 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2416 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2417 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002418 }
2419
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002420 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2421 if (sampler_conversion != nullptr) {
2422 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2423 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2424 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2425 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002426 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002427 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002428 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2429 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2430 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2431 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2432 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2433 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2434 }
2435 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
2437
2438 return skip;
2439}
2440
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002441bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2442 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2443 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002444 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446
2447 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2448 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2449 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2450 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2452 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2453 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2454 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2455 ++descriptor_index) {
2456 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002457 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002458 "vkCreateDescriptorSetLayout: required parameter "
2459 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2460 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 }
2462 }
2463 }
2464
2465 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2466 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2467 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002468 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2469 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2470 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2471 "values.",
2472 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002474
2475 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2476 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2477 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2478 skip |=
2479 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2480 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2481 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2482 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2483 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2484 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485 }
2486 }
2487 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 return skip;
2489}
2490
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002491bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2492 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002493 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2495 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2496 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002497 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2498 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002499}
2500
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002501bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2502 const VkWriteDescriptorSet *pDescriptorWrites,
2503 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002504 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002505
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 if (pDescriptorWrites != NULL) {
2507 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2508 // descriptorCount must be greater than 0
2509 if (pDescriptorWrites[i].descriptorCount == 0) {
2510 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002511 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2512 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002513 }
2514
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002515 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2516 if (validateDstSet) {
2517 // dstSet must be a valid VkDescriptorSet handle
2518 skip |= validate_required_handle(vkCallingFunction,
2519 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2520 pDescriptorWrites[i].dstSet);
2521 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522
2523 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2524 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2525 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2526 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2527 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2528 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2529 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2530 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2531 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002532 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2533 "%s(): if pDescriptorWrites[%d].descriptorType is "
2534 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2535 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2536 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2537 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2539 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2540 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2541 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2542 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2543 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002544 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2546 ParameterName::IndexVector{i, descriptor_index}),
2547 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002548 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2550 ParameterName::IndexVector{i, descriptor_index}),
2551 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002552 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002553 }
2554 }
2555 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2556 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2557 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2558 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2559 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2560 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2561 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2562 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2564 "%s(): if pDescriptorWrites[%d].descriptorType is "
2565 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2566 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2567 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2568 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002569 } else {
2570 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002571 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2573 ParameterName::IndexVector{i, descriptorIndex}),
2574 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2575 }
2576 }
2577 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2578 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2579 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2580 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2581 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002582 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2583 "%s(): if pDescriptorWrites[%d].descriptorType is "
2584 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2585 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2586 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002587 } else {
2588 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2589 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002590 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002591 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2592 ParameterName::IndexVector{i, descriptor_index}),
2593 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2594 }
2595 }
2596 }
2597
2598 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2599 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002600 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2602 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2603 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002604 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002605 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2606 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2607 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2608 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609 }
2610 }
2611 }
2612 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2613 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2616 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2617 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002618 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002619 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2620 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2621 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2622 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623 }
2624 }
2625 }
2626 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002627 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2628 // or VkWriteDescriptorSetInlineUniformBlockEX
2629 if (pDescriptorWrites[i].pNext) {
2630 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2631 const auto *pNext_struct =
2632 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2633 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2634 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2635 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2636 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2637 "accelerationStructureCount %d member equals descriptorCount %d.",
2638 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2639 pDescriptorWrites[i].descriptorCount);
2640 }
2641 // further checks only if we have right structtype
2642 if (pNext_struct) {
2643 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2644 skip |= LogError(
2645 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2646 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2647 ".",
2648 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2649 }
2650 if (pNext_struct->accelerationStructureCount == 0) {
2651 skip |= LogError(
2652 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2653 "%s(): accelerationStructureCount must be greater than 0 .");
2654 }
2655 }
2656 }
2657 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002658 }
2659 }
2660 return skip;
2661}
2662
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002663bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2664 const VkWriteDescriptorSet *pDescriptorWrites,
2665 uint32_t descriptorCopyCount,
2666 const VkCopyDescriptorSet *pDescriptorCopies) const {
2667 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2668}
2669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002670bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002671 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002672 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002673 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2674}
2675
2676bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002677 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002678 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002679 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2680}
2681
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002682bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2683 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002684 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002686
2687 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2688 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2689 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002690 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2691 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 return skip;
2693}
2694
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002695bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002696 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002697 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002698
2699 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2700 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002701 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2702
Petr Krause7bb9e82019-08-11 21:34:43 +02002703 // Implicit VUs
2704 // validate only sType here; pointer has to be validated in core_validation
2705 const bool kNotRequired = false;
2706 const char *kNoVUID = nullptr;
2707 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2708 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2709 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002710
Petr Krause7bb9e82019-08-11 21:34:43 +02002711 if (pInfo) {
2712 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2713 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2714 skip |= validate_struct_pnext(
2715 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2716 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002717 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2718 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719
Petr Krause7bb9e82019-08-11 21:34:43 +02002720 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002721
Petr Krause7bb9e82019-08-11 21:34:43 +02002722 // Explicit VUs
2723 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002724 skip |= LogError(
2725 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002726 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2727 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002729
2730 if (physical_device_features.inheritedQueries) {
2731 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002732 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002733 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002734 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002735 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002736 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002737 }
2738
2739 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002740 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002741 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002742 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002743 } else { // !pipelineStatisticsQuery
2744 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2745 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 }
Petr Kraus139757b2019-08-15 17:19:33 +02002747
2748 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2749 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002750 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002751 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2752 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002753 skip |= LogError(
2754 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002755 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2756 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2757 }
2758 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 }
2760
2761 return skip;
2762}
2763
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002764bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002765 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002767
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002768 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002769 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002770 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2771 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2772 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002773 }
2774 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002775 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2776 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2777 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002778 }
2779 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002780 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002781 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2783 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2784 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2785 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002786 }
2787 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002788
2789 if (pViewports) {
2790 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2791 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002792 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |= manual_PreCallValidateViewport(
2794 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002795 }
2796 }
2797
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798 return skip;
2799}
2800
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002801bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002802 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002804
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002805 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2808 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2809 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002810 }
2811 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002812 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2813 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2814 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002815 }
2816 } else { // multiViewport enabled
2817 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002818 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002819 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2820 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2821 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2822 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 }
2824 }
2825
Petr Kraus6260f0a2018-02-27 21:15:55 +01002826 if (pScissors) {
2827 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2828 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002829
Petr Kraus6260f0a2018-02-27 21:15:55 +01002830 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002831 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2832 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2833 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002834 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835
Petr Kraus6260f0a2018-02-27 21:15:55 +01002836 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002837 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2838 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2839 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002840 }
2841
2842 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2843 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002844 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2845 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2846 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2847 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002848 }
2849
2850 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2851 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002852 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2853 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2854 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2855 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002856 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 }
2858 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002859
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002860 return skip;
2861}
2862
Jeff Bolz5c801d12019-10-09 10:38:45 -05002863bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002864 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002865
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002866 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002867 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2868 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002869 }
2870
2871 return skip;
2872}
2873
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002874bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002875 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002877 if (vertexCount == 0) {
2878 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2879 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002880 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 }
2882
2883 if (instanceCount == 0) {
2884 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2885 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002886 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002887 }
2888 return skip;
2889}
2890
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002891bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002892 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002894
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002895 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002896 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2897 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898 }
2899 return skip;
2900}
2901
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002902bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002903 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002904 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002905 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |=
2907 LogError(device, kVUID_PVError_DeviceFeature,
2908 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 }
2910 return skip;
2911}
2912
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002913bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2914 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002915 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002916 bool skip = false;
2917 for (uint32_t rect = 0; rect < rectCount; rect++) {
2918 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002919 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2920 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002921 }
sfricke-samsung10867682020-04-25 02:20:39 -07002922 if (pRects[rect].rect.extent.width == 0) {
2923 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
2924 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
2925 }
2926 if (pRects[rect].rect.extent.height == 0) {
2927 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
2928 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
2929 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002930 }
2931 return skip;
2932}
2933
Andrew Fobel3abeb992020-01-20 16:33:22 -05002934bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2935 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2936 VkImageFormatProperties2 *pImageFormatProperties,
2937 const char *apiName) const {
2938 bool skip = false;
2939
2940 if (pImageFormatInfo != nullptr) {
2941 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2942 if (image_stencil_struct != nullptr) {
2943 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2944 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2945 // No flags other than the legal attachment bits may be set
2946 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2947 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002948 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2949 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2950 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2951 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2952 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002953 }
2954 }
2955 }
2956 }
2957
2958 return skip;
2959}
2960
2961bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2962 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2963 VkImageFormatProperties2 *pImageFormatProperties) const {
2964 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2965 "vkGetPhysicalDeviceImageFormatProperties2");
2966}
2967
2968bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2969 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2970 VkImageFormatProperties2 *pImageFormatProperties) const {
2971 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2972 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2973}
2974
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002975bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2976 VkImageLayout srcImageLayout, VkImage dstImage,
2977 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002978 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002979 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980
Dave Houltonf5217612018-02-02 16:18:52 -07002981 VkImageAspectFlags legal_aspect_flags =
2982 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 -07002983 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002984 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2985 }
2986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002988 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002989 skip |= LogError(
2990 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002991 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002992 }
Dave Houltonf5217612018-02-02 16:18:52 -07002993 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002994 skip |= LogError(
2995 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002996 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002997 }
2998 }
2999 return skip;
3000}
3001
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003002bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3003 VkImageLayout srcImageLayout, VkImage dstImage,
3004 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003005 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003006 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003007
Dave Houltonf5217612018-02-02 16:18:52 -07003008 VkImageAspectFlags legal_aspect_flags =
3009 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 -07003010 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003011 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3012 }
3013
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003015 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003016 skip |= LogError(
3017 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003018 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3019 }
Dave Houltonf5217612018-02-02 16:18:52 -07003020 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003021 skip |= LogError(
3022 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3024 }
3025 }
3026 return skip;
3027}
3028
sfricke-samsung3999ef62020-02-09 17:05:59 -08003029bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3030 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3031 bool skip = false;
3032
3033 if (pRegions != nullptr) {
3034 for (uint32_t i = 0; i < regionCount; i++) {
3035 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3037 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003038 }
3039 }
3040 }
3041 return skip;
3042}
3043
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003044bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3045 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003046 uint32_t regionCount,
3047 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003049
Dave Houltonf5217612018-02-02 16:18:52 -07003050 VkImageAspectFlags legal_aspect_flags =
3051 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 -07003052 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003053 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3054 }
3055
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003056 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003057 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3059 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3060 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003061 }
3062 }
3063 return skip;
3064}
3065
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003066bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3067 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003068 uint32_t regionCount,
3069 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071
Dave Houltonf5217612018-02-02 16:18:52 -07003072 VkImageAspectFlags legal_aspect_flags =
3073 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 -07003074 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003075 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3076 }
3077
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003079 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003080 skip |= LogError(
3081 device, kVUID_PVError_UnrecognizedValue,
3082 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3083 "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_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003090 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3091 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093
3094 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003095 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3096 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3097 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003098 }
3099
3100 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003101 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3102 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3103 "), must be greater than zero and less than or equal to 65536.",
3104 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3107 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3108 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109 }
3110 return skip;
3111}
3112
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003113bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003114 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) 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-vkCmdFillBuffer-dstOffset-00025",
3119 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3120 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 }
3122
3123 if (size != VK_WHOLE_SIZE) {
3124 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003125 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003126 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3127 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003129 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3130 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131 }
3132 }
3133 return skip;
3134}
3135
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003136bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003137 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003138 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003140
3141 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3143 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3144 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3145 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003146 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3147 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3148 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149 }
3150
3151 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3152 // queueFamilyIndexCount uint32_t values
3153 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3155 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3156 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3157 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 }
3159 }
3160
Dave Houlton413a6782018-05-22 13:01:54 -06003161 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003162 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003163 }
3164
3165 return skip;
3166}
3167
Jeff Bolz5c801d12019-10-09 10:38:45 -05003168bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003169 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170
3171 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003172 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3173 if (present_regions) {
3174 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003175 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003176 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3177 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003178 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3179 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3180 "extension swapchainCount is %i. These values must be equal.",
3181 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003182 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003183 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003184 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3185 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003186 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3187 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3188 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003189 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003190 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003191 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003192 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194 }
3195 }
3196
3197 return skip;
3198}
3199
3200#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003201bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3202 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3203 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003204 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003205 bool skip = false;
3206
3207 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3209 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 }
3211
3212 return skip;
3213}
3214#endif // VK_USE_PLATFORM_WIN32_KHR
3215
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003216bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003217 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003218 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003219 bool skip = false;
3220
3221 if (pCreateInfo) {
3222 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003223 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3224 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003225 }
3226
3227 if (pCreateInfo->pPoolSizes) {
3228 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3229 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003230 skip |= LogError(
3231 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003232 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003233 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003234 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3235 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003236 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3237 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3238 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3239 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3240 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003241 }
Petr Krausc8655be2017-09-27 18:56:51 +02003242 }
3243 }
3244 }
3245
3246 return skip;
3247}
3248
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003249bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003250 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003251 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003252
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003253 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003254 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003255 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3256 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3257 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003258 }
3259
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003260 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003261 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003262 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3263 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3264 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003265 }
3266
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003267 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003268 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003269 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3270 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3271 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003272 }
3273
3274 return skip;
3275}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003276
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003277bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003278 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003279 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003280
3281 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3283 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003284 }
3285 return skip;
3286}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003287
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003288bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3289 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003290 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003291 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003292
3293 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003294 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003295 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003296 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3297 "vkCmdDispatch(): baseGroupX (%" PRIu32
3298 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3299 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003300 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003301 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3302 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3303 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3304 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003305 }
3306
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003307 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003308 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003309 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3310 "vkCmdDispatch(): baseGroupY (%" PRIu32
3311 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3312 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003313 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003314 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3315 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3316 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3317 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003318 }
3319
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003320 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003321 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3323 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3324 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3325 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003326 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003327 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3328 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3329 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3330 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003331 }
3332
3333 return skip;
3334}
3335
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003336bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3337 VkPipelineBindPoint pipelineBindPoint,
3338 VkPipelineLayout layout, uint32_t set,
3339 uint32_t descriptorWriteCount,
3340 const VkWriteDescriptorSet *pDescriptorWrites) const {
3341 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3342}
3343
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003344bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3345 uint32_t firstExclusiveScissor,
3346 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003347 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003348 bool skip = false;
3349
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003350 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003351 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003352 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003353 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3354 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3355 ") is not 0.",
3356 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003357 }
3358 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003359 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003360 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3361 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3362 ") is not 1.",
3363 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003364 }
3365 } else { // multiViewport enabled
3366 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003367 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003368 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3369 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3370 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3371 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003372 }
3373 }
3374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003375 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003376 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3377 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3378 ") must be less than maxViewports (=%" PRIu32 ").",
3379 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003380 }
3381
3382 if (pExclusiveScissors) {
3383 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3384 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3385
3386 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003387 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3388 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3389 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003390 }
3391
3392 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003393 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3394 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3395 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003396 }
3397
3398 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3399 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003400 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3401 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3402 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3403 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003404 }
3405
3406 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3407 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003408 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3409 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3410 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3411 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003412 }
3413 }
3414 }
3415
3416 return skip;
3417}
3418
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003419bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3420 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003421 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003422 bool skip = false;
3423 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3425 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3426 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003427 } else {
3428 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3429 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003430 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3431 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3432 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3433 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003434 }
3435 }
3436
3437 return skip;
3438}
3439
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003440bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3441 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003442 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003443 bool skip = false;
3444
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003445 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003446 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003447 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003448 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3449 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3450 ") is not 0.",
3451 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003452 }
3453 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003454 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003455 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3456 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3457 ") is not 1.",
3458 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003459 }
3460 }
3461
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003462 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003463 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3464 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3465 ") must be less than maxViewports (=%" PRIu32 ").",
3466 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003467 }
3468
3469 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003470 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003471 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3472 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3473 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3474 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003475 }
3476
3477 return skip;
3478}
3479
Jeff Bolz5c801d12019-10-09 10:38:45 -05003480bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3481 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3482 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003483 bool skip = false;
3484
Dave Houlton142c4cb2018-10-17 15:04:41 -06003485 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003486 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3487 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3488 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003489 }
3490
3491 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003492 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003493 }
3494
3495 return skip;
3496}
3497
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003498bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003499 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003500 bool skip = false;
3501
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003502 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003503 skip |= LogError(
3504 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003505 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3506 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003507 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003508 }
3509
3510 return skip;
3511}
3512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003513bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3514 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003515 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003516 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003517 static const int condition_multiples = 0b0011;
3518 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 skip |= LogError(
3520 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003521 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003522 }
Lockee1c22882019-06-10 16:02:54 -06003523 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3525 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3526 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3527 stride);
Lockee1c22882019-06-10 16:02:54 -06003528 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003529 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003530 skip |= LogError(
3531 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3532 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003533 }
3534
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003535 return skip;
3536}
3537
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003538bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3539 VkDeviceSize offset, VkBuffer countBuffer,
3540 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003541 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003542 bool skip = false;
3543
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003544 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3546 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3547 "), is not a multiple of 4.",
3548 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003549 }
3550
3551 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003552 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3553 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3554 "), is not a multiple of 4.",
3555 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003556 }
3557
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003558 return skip;
3559}
3560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003561bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003562 const VkAllocationCallbacks *pAllocator,
3563 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003564 bool skip = false;
3565
3566 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3567 if (pCreateInfo != nullptr) {
3568 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3569 // VkQueryPipelineStatisticFlagBits values
3570 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3571 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003572 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3573 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3574 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3575 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003576 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003577 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003578 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003579}
3580
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003581bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3582 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003583 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003584 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3585 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586}
3587
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003588void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003589 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3590 VkResult result) {
3591 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003592 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593}
3594
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003595void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003596 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3597 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003598 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003599 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003600 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601}
3602
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003603void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3604 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003605 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003606 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003607 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003609
3610bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003611 const VkAllocationCallbacks *pAllocator,
3612 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003613 bool skip = false;
3614
3615 if (pAllocateInfo) {
3616 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3617 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3619 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003620 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003621
3622 VkMemoryAllocateFlags flags = 0;
3623 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3624 if (flags_info) {
3625 flags = flags_info->flags;
3626 }
3627
3628 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3629 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3630 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003631 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3632 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3633 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003634 }
3635
3636#ifdef VK_USE_PLATFORM_WIN32_KHR
3637 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3638#endif
3639 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3640 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3641#ifdef VK_USE_PLATFORM_ANDROID_KHR
3642 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3643#endif
3644
3645 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003646 skip |= LogError(
3647 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003648 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3649 }
3650 if (
3651#ifdef VK_USE_PLATFORM_WIN32_KHR
3652 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3653#endif
3654 (import_memory_fd && import_memory_fd->handleType) ||
3655#ifdef VK_USE_PLATFORM_ANDROID_KHR
3656 (import_memory_ahb && import_memory_ahb->buffer) ||
3657#endif
3658 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003659 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3660 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003661 }
3662 }
3663
3664 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003665 VkBool32 capture_replay = false;
3666 VkBool32 buffer_device_address = false;
3667 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3668 if (vulkan_12_features) {
3669 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3670 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3671 } else {
3672 const auto *bda_features =
3673 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3674 if (bda_features) {
3675 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3676 buffer_device_address = bda_features->bufferDeviceAddress;
3677 }
3678 }
3679 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003680 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3681 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3682 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003683 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003684 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3686 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003687 }
3688 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003689 }
3690 return skip;
3691}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003692
Jason Macnak192fa0e2019-07-26 15:07:16 -07003693bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003694 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003695 bool skip = false;
3696
3697 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3698 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3699 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003700 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003701 } else {
3702 uint32_t vertex_component_size = 0;
3703 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3704 vertex_component_size = 4;
3705 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3706 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3707 vertex_component_size = 2;
3708 }
3709 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003710 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003711 }
3712 }
3713
3714 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3715 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003717 } else {
3718 uint32_t index_element_size = 0;
3719 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3720 index_element_size = 4;
3721 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3722 index_element_size = 2;
3723 }
3724 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003725 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003726 }
3727 }
3728 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3729 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003730 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003731 }
3732 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003733 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003734 }
3735 }
3736
3737 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003738 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003739 }
3740
3741 return skip;
3742}
3743
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3745 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003746 bool skip = false;
3747
3748 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003750 }
3751 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003752 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003753 }
3754
3755 return skip;
3756}
3757
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003758bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3759 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003760 bool skip = false;
3761 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003762 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003763 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003764 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003765 }
3766 return skip;
3767}
3768
3769bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003771 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003772 bool skip = false;
3773 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003774 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3775 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3776 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003777 }
3778 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003779 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3780 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3781 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003782 }
3783 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3784 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003785 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3786 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3787 "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 -07003788 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003789 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003790 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3791 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3792 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003793 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003794 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003795 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3796 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3797 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003798 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003799 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003800 uint64_t total_triangle_count = 0;
3801 for (uint32_t i = 0; i < info.geometryCount; i++) {
3802 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003803
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003804 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003805
Jason Macnak5c954952019-07-09 15:46:12 -07003806 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3807 continue;
3808 }
3809 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3810 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003811 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003812 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3813 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3814 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003815 }
3816 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003817 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3818 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3819 for (uint32_t i = 1; i < info.geometryCount; i++) {
3820 const VkGeometryNV &geometry = info.pGeometries[i];
3821 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003822 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003823 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3824 "info.pGeometries[0].geometryType.",
3825 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003826 }
3827 }
3828 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003829 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3830 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3831 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3832 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3833 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3834 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3835 }
3836 }
3837 skip |=
3838 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3839 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003840 return skip;
3841}
3842
Ricardo Garciaa4935972019-02-21 17:43:18 +01003843bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3844 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003845 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003846 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003847 if (pCreateInfo) {
3848 if ((pCreateInfo->compactedSize != 0) &&
3849 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003850 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3851 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3852 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3853 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003854 }
Jason Macnak5c954952019-07-09 15:46:12 -07003855
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003857 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003858 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003859 return skip;
3860}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003861
Jeff Bolz5c801d12019-10-09 10:38:45 -05003862bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3863 const VkAccelerationStructureInfoNV *pInfo,
3864 VkBuffer instanceData, VkDeviceSize instanceOffset,
3865 VkBool32 update, VkAccelerationStructureNV dst,
3866 VkAccelerationStructureNV src, VkBuffer scratch,
3867 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003868 bool skip = false;
3869
3870 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003871 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003872 }
3873
3874 return skip;
3875}
3876
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003877bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
3878 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3879 VkAccelerationStructureKHR *pAccelerationStructure) const {
3880 bool skip = false;
3881
3882 if (pCreateInfo) {
3883 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
3884 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3885 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3886 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
3887 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
3888 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3889 i);
3890 }
3891 }
3892
3893 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3894 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3895 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
3896 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
3897 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3898 i);
3899 }
3900 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003901 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
3902 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
3903 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
3904 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
3905 skip |= LogError(
3906 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
3907 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
3908 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
3909 }
3910 }
3911 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
3912 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
3913 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
3914 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3915 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
3916 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
3917 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
3918 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
3919 }
3920 }
3921 }
3922
3923 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
3924 pCreateInfo->maxGeometryCount != 1) {
3925 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
3926 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3927 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003928 }
3929
3930 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
3931 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
3932 skip |= LogError(
3933 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
3934 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
3935 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
3936 }
3937
3938 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
3939 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
3940 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
3941 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
3942 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
3943 }
3944
3945 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
3946 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
3947 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
3948 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
3949 if (geometry_type != first_geometry_type) {
3950 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
3951 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
3952 "pGeometryInfos[0].geometryType.",
3953 i);
3954 }
3955 }
3956 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003957 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
3958 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
3959 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
3960 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
3961 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
3962 "maxGeometryCount %d.",
3963 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
3964 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003965 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003966 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
3967 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
3968 if (pCreateInfo->deviceAddress != 0) {
3969 skip |=
3970 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
3971 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
3972 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
3973 }
3974 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003975 return skip;
3976}
3977
Jason Macnak5c954952019-07-09 15:46:12 -07003978bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3979 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003980 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003981 bool skip = false;
3982 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003983 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3984 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003985 }
3986 return skip;
3987}
3988
Peter Chen85366392019-05-14 15:20:11 -04003989bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3990 uint32_t createInfoCount,
3991 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3992 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003993 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003994 bool skip = false;
3995
3996 for (uint32_t i = 0; i < createInfoCount; i++) {
3997 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3998 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4000 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4001 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4002 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4003 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004004 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004005
4006 const auto *pipeline_cache_contol_features =
4007 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4008 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4009 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4010 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4011 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4012 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4013 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4014 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4015 }
4016 }
4017
sourav parmarf4a78252020-04-10 13:04:21 -07004018 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4019 skip |=
4020 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4021 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4022 }
4023 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4024 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4025 skip |=
4026 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4027 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4028 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4029 }
4030 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4031 if (pCreateInfos[i].basePipelineIndex != -1) {
4032 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4033 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4034 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4035 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4036 "and pCreateInfos->basePipelineIndex is not -1.");
4037 }
4038 }
4039 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4040 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4041 skip |=
4042 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4043 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4044 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4045 "commands pCreateInfos parameter.");
4046 }
4047 } else {
4048 if (pCreateInfos[i].basePipelineIndex != -1) {
4049 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4050 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4051 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4052 }
4053 }
4054 }
4055 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4056 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4057 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4058 }
4059 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4060 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4061 "vkCreateRayTracingPipelinesNV: flags must not include "
4062 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4063 }
4064 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4065 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4066 "vkCreateRayTracingPipelinesNV: flags must not include "
4067 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4068 }
4069 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4070 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4071 "vkCreateRayTracingPipelinesNV: flags must not include "
4072 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4073 }
4074 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4075 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4076 "vkCreateRayTracingPipelinesNV: flags must not include "
4077 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4078 }
4079 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4080 skip |= LogError(
4081 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4082 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4083 }
4084 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4085 skip |= LogError(
4086 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4087 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4088 }
Peter Chen85366392019-05-14 15:20:11 -04004089 }
4090
4091 return skip;
4092}
4093
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004094bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4095 uint32_t createInfoCount,
4096 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4097 const VkAllocationCallbacks *pAllocator,
4098 VkPipeline *pPipelines) const {
4099 bool skip = false;
4100
4101 for (uint32_t i = 0; i < createInfoCount; i++) {
4102 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4103 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4104 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4105 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4106 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4107 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4108 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4109 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004110 const auto *pipeline_cache_contol_features =
4111 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4112 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4113 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4114 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4115 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4116 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4117 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4118 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4119 }
4120 }
4121 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4122 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4123 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4124 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4125 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4126 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4127 }
4128 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4129 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4130 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4131 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4132 }
4133 }
4134
sourav parmarf4a78252020-04-10 13:04:21 -07004135 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4136 skip |=
4137 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4138 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4139 }
4140 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4141 if (pCreateInfos[i].pLibraryInterface == NULL)
4142 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4143 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4144 }
4145 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4146 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4147 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4148 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4149 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4150 skip |= LogError(
4151 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4152 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4153 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4154 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4155 "must not be VK_SHADER_UNUSED_KHR");
4156 }
4157 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4158 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4159 skip |= LogError(
4160 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4161 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4162 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4163 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4164 "element must not be VK_SHADER_UNUSED_KHR");
4165 }
4166 }
4167 }
4168 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4169 if (pCreateInfos[i].basePipelineIndex != -1) {
4170 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4171 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4172 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4173 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4174 "and pCreateInfos->basePipelineIndex is not -1.");
4175 }
4176 }
4177 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4178 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4179 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4180 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4181 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4182 "commands pCreateInfos parameter %d.",
4183 pCreateInfos[i].basePipelineIndex, createInfoCount);
4184 }
4185 } else {
4186 if (pCreateInfos[i].basePipelineIndex != -1) {
4187 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4188 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4189 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4190 }
4191 }
4192 }
4193 if (pCreateInfos[i].libraries.libraryCount == 0) {
4194 if (pCreateInfos[i].stageCount == 0) {
4195 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4196 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4197 }
4198 if (pCreateInfos[i].groupCount == 0) {
4199 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4200 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4201 }
4202 } else {
4203 if (pCreateInfos[i].pLibraryInterface == NULL) {
4204 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4205 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4206 }
4207 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004208 }
4209
4210 return skip;
4211}
4212
Mike Schuchardt21638df2019-03-16 10:52:02 -07004213#ifdef VK_USE_PLATFORM_WIN32_KHR
4214bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4215 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004216 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004217 bool skip = false;
4218 if (!device_extensions.vk_khr_swapchain)
4219 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4220 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4221 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4222 if (!device_extensions.vk_khr_surface)
4223 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4224 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4225 skip |=
4226 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4227 if (!device_extensions.vk_ext_full_screen_exclusive)
4228 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4229 skip |= validate_struct_type(
4230 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4231 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4232 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4233 if (pSurfaceInfo != NULL) {
4234 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4235 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4236 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4237
4238 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4239 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4240 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4241 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004242 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4243 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004244
4245 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4246 }
4247 return skip;
4248}
4249#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004250
4251bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4252 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004253 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004254 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4255 bool skip = false;
4256 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4257 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4258 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4259 }
4260 return skip;
4261}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004262
4263bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004264 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004265 bool skip = false;
4266
4267 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004268 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4269 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004270 }
4271
4272 return skip;
4273}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004274
4275bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004276 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004277 bool skip = false;
4278
4279 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004280 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4281 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004282 }
4283
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004284 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06004285 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004286 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4287 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004288 }
4289
4290 return skip;
4291}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004292
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004293bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4294 uint32_t bindingCount, const VkBuffer *pBuffers,
4295 const VkDeviceSize *pOffsets) const {
4296 bool skip = false;
4297 if (firstBinding > device_limits.maxVertexInputBindings) {
4298 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4299 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4300 device_limits.maxVertexInputBindings);
4301 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4302 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4303 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4304 "maxVertexInputBindings (%u)",
4305 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4306 }
4307
4308 return skip;
4309}
4310
Mark Lobodzinski84988402019-09-11 15:27:30 -06004311bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004312 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004313 bool skip = false;
4314 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004315 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4316 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004317 }
4318 return skip;
4319}
4320
4321bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004322 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004323 bool skip = false;
4324 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004325 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4326 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004327 }
4328 return skip;
4329}
Petr Kraus3d720392019-11-13 02:52:39 +01004330
4331bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4332 VkSemaphore semaphore, VkFence fence,
4333 uint32_t *pImageIndex) const {
4334 bool skip = false;
4335
4336 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004337 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4338 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004339 }
4340
4341 return skip;
4342}
4343
4344bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4345 uint32_t *pImageIndex) const {
4346 bool skip = false;
4347
4348 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004349 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4350 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004351 }
4352
4353 return skip;
4354}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004355
4356bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4357 uint32_t firstInstance, VkBuffer counterBuffer,
4358 VkDeviceSize counterBufferOffset,
4359 uint32_t counterOffset, uint32_t vertexStride) const {
4360 bool skip = false;
4361
4362 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004363 skip |= LogError(
4364 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004365 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4366 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4367 }
4368
4369 return skip;
4370}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004371
4372bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4373 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4374 const VkAllocationCallbacks *pAllocator,
4375 VkSamplerYcbcrConversion *pYcbcrConversion,
4376 const char *apiName) const {
4377 bool skip = false;
4378
4379 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004380 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004381 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4383 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004384 }
4385 return skip;
4386}
4387
4388bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4389 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4390 const VkAllocationCallbacks *pAllocator,
4391 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4392 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4393 "vkCreateSamplerYcbcrConversion");
4394}
4395
4396bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4397 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4398 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4399 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4400 "vkCreateSamplerYcbcrConversionKHR");
4401}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004402
4403bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4404 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4405 bool skip = false;
4406 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4407 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4408
4409 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4411 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4412 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4413 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4414 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004415 }
4416 return skip;
4417}
sourav parmara96ab1a2020-04-25 16:28:23 -07004418
4419bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4420 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4421 bool skip = false;
4422 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4423 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4424 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4425 }
4426 return skip;
4427}
4428
4429bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4430 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4431 bool skip = false;
4432 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4433 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4434 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4435 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4436 }
4437 return skip;
4438}
4439
4440bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4441 const char *api_name) const {
4442 bool skip = false;
4443 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4444 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4445 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4446 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4447 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4448 api_name);
4449 }
4450 return skip;
4451}
4452
4453bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4454 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4455 bool skip = false;
4456 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
4457 return skip;
4458}
4459
4460bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4461 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4462 bool skip = false;
4463 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4464 return skip;
4465}
4466
4467bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
4468 const char *api_name) const {
4469 bool skip = false;
4470 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
4471 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
4472 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4473 }
4474 return skip;
4475}
4476
4477bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4478 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4479 bool skip = false;
4480 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()");
4481 return skip;
4482}
4483bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4484 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4485 bool skip = false;
4486 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()");
4487 return skip;
4488}