blob: 405a129b07183871bb1fb322b95fc705e3ef5d3d [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 bool skip = false;
101 // Note: From the spec--
102 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
103 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
104 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
121void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700122 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700123 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700124 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700125 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
126 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700128 // Parmeter validation also uses extension data
129 stateless_validation->device_extensions = this->device_extensions;
130
131 VkPhysicalDeviceProperties device_properties = {};
132 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600133 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700134 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
135
136 if (device_extensions.vk_nv_shading_rate_image) {
137 // Get the needed shading rate image limits
138 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
139 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600140 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700141 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
142 }
143
144 if (device_extensions.vk_nv_mesh_shader) {
145 // Get the needed mesh shader limits
146 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
147 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
150 }
151
Jason Macnak5c954952019-07-09 15:46:12 -0700152 if (device_extensions.vk_nv_ray_tracing) {
153 // Get the needed ray tracing limits
154 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
155 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
156 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500157 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
158 }
159
160 if (device_extensions.vk_khr_ray_tracing) {
161 // Get the needed ray tracing limits
162 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700166 }
167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700168 if (device_extensions.vk_ext_transform_feedback) {
169 // Get the needed transform feedback limits
170 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
171 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
172 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
173 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
174 }
175
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800176 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 // Save app-enabled features in this device's validation object
179 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
181 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
182 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 if (features2) {
184 tmp_features2_state.features = features2->features;
185 } else if (pCreateInfo->pEnabledFeatures) {
186 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200188 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200190 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700191 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200192 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700193}
194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500196 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600197 bool skip = false;
198
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200199 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
200 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
201 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
205 skip |=
206 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
207 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
208 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
209 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600210 }
211
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700213 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
214 bool negative_viewport =
215 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200216 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700217 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
218 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
219 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600223 {
224 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
225 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
226 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700227 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
228 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
229 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 }
231 }
232
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
234 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600235 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
236 if (features2) {
237 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700238 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700239 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
240 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600241 }
242 }
243
Locke77fad1c2019-04-16 13:09:03 -0600244 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
245 if (features2) {
246 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700247 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
248 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
249 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600250 }
251 }
252
253 auto vertex_attribute_divisor_features =
254 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
255 if (vertex_attribute_divisor_features) {
256 bool extension_found = false;
257 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
258 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
259 VK_MAX_EXTENSION_NAME_SIZE)) {
260 extension_found = true;
261 break;
262 }
263 }
264 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700265 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
266 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
267 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600268 }
269 }
270
Tony-LunarG28017bc2020-01-23 14:40:25 -0700271 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
272 if (vulkan_11_features) {
273 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
274 while (current) {
275 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
276 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
277 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
278 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
279 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
280 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700281 skip |= LogError(
282 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700283 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
284 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
285 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
286 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
287 break;
288 }
289 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
290 }
291 }
292
293 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
294 if (vulkan_12_features) {
295 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
296 while (current) {
297 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
298 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
299 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
300 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
301 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
302 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
303 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
304 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700310 skip |= LogError(
311 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700312 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
313 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
314 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
315 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
316 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
317 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
318 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
319 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
320 break;
321 }
322 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
323 }
324 }
325
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600326 // Validate pCreateInfo->pQueueCreateInfos
327 if (pCreateInfo->pQueueCreateInfos) {
328 std::unordered_set<uint32_t> set;
329
330 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700331 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
332 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600333 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700334 skip |=
335 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
336 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
337 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
338 "index value.",
339 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600340 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700341 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
342 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
343 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
344 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600345 } else {
346 set.insert(requested_queue_family);
347 }
348
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700349 if (queue_create_info.pQueuePriorities != nullptr) {
350 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
351 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600352 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700353 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
354 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
355 "] (=%f) is not between 0 and 1 (inclusive).",
356 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600357 }
358 }
359 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700360
361 // Need to know if protectedMemory feature is passed in preCall to creating the device
362 VkBool32 protectedMemory = VK_FALSE;
363 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
364 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
365 if (protected_features) {
366 protectedMemory = protected_features->protectedMemory;
367 } else if (vulkan_11_features) {
368 protectedMemory = vulkan_11_features->protectedMemory;
369 }
370 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
371 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
372 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
373 "protectedMemory feature being set as well.");
374 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600375 }
376 }
377
378 return skip;
379}
380
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500381bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700382 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700383 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
384 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
385 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600386 }
387
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700388 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600389}
390
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700391bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500392 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100393 bool skip = false;
394
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600395 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700396 skip |=
397 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600398
399 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
400 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
401 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
402 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700403 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
404 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
405 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600406 }
407
408 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
409 // queueFamilyIndexCount uint32_t values
410 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700411 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
412 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
413 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
414 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600415 }
416 }
417
418 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
419 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
420 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
421 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700422 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
423 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
424 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600425 }
426 }
427
428 return skip;
429}
430
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700431bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500432 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600433 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434
435 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600436 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
437 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
438 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
439 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700440 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
441 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
442 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600443 }
444
445 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
446 // queueFamilyIndexCount uint32_t values
447 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
449 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
450 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
451 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454
Dave Houlton413a6782018-05-22 13:01:54 -0600455 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700456 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600457 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700458 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600459 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700460 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600461
Dave Houlton413a6782018-05-22 13:01:54 -0600462 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600464 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700465 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466
Dave Houlton130c0212018-01-29 13:39:56 -0700467 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700468 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
469 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700470 skip |= LogError(
471 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600472 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
473 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700474 }
475
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600476 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100477 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
478 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
480 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
481 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482 }
483
484 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100485 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
486 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
488 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
489 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
490 ") are not equal.",
491 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100492 }
493
494 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700495 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
496 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
497 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
498 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100499 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500 }
501
502 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700503 skip |= LogError(
504 device, "VUID-VkImageCreateInfo-imageType-00957",
505 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 }
507 }
508
Dave Houlton130c0212018-01-29 13:39:56 -0700509 // 3D image may have only 1 layer
510 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
512 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700513 }
514
515 // If multi-sample, validate type, usage, tiling and mip levels.
516 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
517 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600518 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700519 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
520 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700521 }
522
523 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
524 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
525 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
526 // At least one of the legal attachment bits must be set
527 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700528 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
529 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700530 }
531 // No flags other than the legal attachment bits may be set
532 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
533 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700534 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
535 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700536 }
537 }
538
Jeff Bolzef40fec2018-09-01 22:04:34 -0500539 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500541 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600542 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
543 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500544 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600545 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700546 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
547 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
548 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600551 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
553 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
554 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600555 }
556
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700557 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700558 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
559 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
560 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100561 }
562
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600563 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
564 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
565 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
566 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
568 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
569 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 }
571
572 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
573 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
574 // Linear tiling is unsupported
575 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, kVUID_PVError_InvalidUsage,
577 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
578 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600579 }
580
581 // Sparse 1D image isn't valid
582 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700583 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
584 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 }
586
587 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700588 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700589 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
590 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
591 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600592 }
593
594 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700595 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
597 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
598 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 }
600
601 // Multi-sample 2D image when device doesn't support it
602 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700603 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600604 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700605 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
606 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
607 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700608 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600609 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
611 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
612 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700613 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
616 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
617 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700618 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600619 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700620 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
621 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
622 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600623 }
624 }
625 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500626
Jeff Bolz9af91c52018-09-01 21:53:57 -0500627 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
628 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
630 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
631 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500632 }
633 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
635 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
636 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500637 }
638 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700639 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
640 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
641 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500642 }
643 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500644
645 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600646 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700647 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
648 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
649 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500650 }
651
Dave Houlton142c4cb2018-10-17 15:04:41 -0600652 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
654 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
655 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
656 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500657 }
658
Dave Houlton142c4cb2018-10-17 15:04:41 -0600659 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700660 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
661 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
662 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
663 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500664 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600665 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700666 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
667 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
668 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
669 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500670 }
671 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500672
673 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
674 if (image_stencil_struct != nullptr) {
675 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
676 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
677 // No flags other than the legal attachment bits may be set
678 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
679 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
681 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
682 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
683 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500684 }
685 }
686
687 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
688 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
689 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
690 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
692 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
693 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
694 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500695 }
696
697 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
698 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 LogError(device, "VUID-VkImageCreateInfo-format-02537",
700 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
701 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
702 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500703 }
704 }
705
706 if (!physical_device_features.shaderStorageImageMultisample &&
707 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
708 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
709 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 LogError(device, "VUID-VkImageCreateInfo-format-02538",
711 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
712 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
713 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500714 }
715
716 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
717 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(
719 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500720 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
721 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
722 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
723 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
724 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(
726 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500727 "vkCreateImage(): Depth-stencil image in which usage does not include "
728 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
729 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
730 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
731 }
732
733 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
734 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700735 skip |= LogError(
736 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500737 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
738 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
739 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
740 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
741 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(
743 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500744 "vkCreateImage(): Depth-stencil image in which usage does not include "
745 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
746 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
747 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
748 }
749 }
750 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700751
752 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
753 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
754 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
755 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
756 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
757 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700758
759 if (device_extensions.vk_ext_image_drm_format_modifier) {
760 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
761 const auto drm_format_mod_explict =
762 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
763 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
764 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
765 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
766 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
767 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
768 "either VkImageDrmFormatModifierListCreateInfoEXT or "
769 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
770 }
771 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
772 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
773 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
774 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
775 "in the pNext chain");
776 }
777 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600778 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500779
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600780 return skip;
781}
782
Jeff Bolz99e3f632020-03-24 22:59:22 -0500783bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
784 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
785 bool skip = false;
786
787 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700788 // Validate feature set if using CUBE_ARRAY
789 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
790 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
791 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
792 "enabling the imageCubeArray feature.");
793 }
794
Jeff Bolz99e3f632020-03-24 22:59:22 -0500795 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
796 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
797 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700798 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500799 pCreateInfo->subresourceRange.layerCount);
800 }
801 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700802 skip |= LogError(
803 device, "VUID-VkImageViewCreateInfo-viewType-02961",
804 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
805 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500806 }
807 }
808 }
809 return skip;
810}
811
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600812bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700813 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100814 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100815
816 // Note: for numerical correctness
817 // - float comparisons should expect NaN (comparison always false).
818 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
819
820 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700821 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100822 if (v1_f <= 0.0f) return true;
823
824 float intpart;
825 const float fract = modff(v1_f, &intpart);
826
827 assert(std::numeric_limits<float>::radix == 2);
828 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
829 if (intpart >= u32_max_plus1) return false;
830
831 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
832 if (v1_u32 < v2_u32)
833 return true;
834 else if (v1_u32 == v2_u32 && fract == 0.0f)
835 return true;
836 else
837 return false;
838 };
839
840 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
841 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
842 return (v1_f <= v2_f);
843 };
844
845 // width
846 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700847 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100848
849 if (!(viewport.width > 0.0f)) {
850 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
852 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100853 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
854 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700855 skip |= LogError(object, "VUID-VkViewport-width-01771",
856 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
857 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100858 } 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 -0700859 skip |= LogWarning(object, kVUID_PVError_NONE,
860 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
861 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
862 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100863 }
864
865 // height
866 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700867 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700868 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100869
870 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
871 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700872 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
873 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100874 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
875 height_healthy = false;
876
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700877 skip |= LogError(object, "VUID-VkViewport-height-01773",
878 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
879 ").",
880 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100881 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
882 height_healthy = false;
883
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700884 skip |= LogWarning(
885 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100886 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600887 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600888 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100889 }
890
891 // x
892 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700893 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100894 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700895 skip |= LogError(object, "VUID-VkViewport-x-01774",
896 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
897 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100898 }
899
900 // x + width
901 if (x_healthy && width_healthy) {
902 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700903 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 skip |= LogError(
905 object, "VUID-VkViewport-x-01232",
906 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
907 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
908 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100909 }
910 }
911
912 // y
913 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700914 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100915 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700916 skip |= LogError(object, "VUID-VkViewport-y-01775",
917 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
918 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700919 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100920 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700921 skip |= LogError(object, "VUID-VkViewport-y-01776",
922 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
923 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100924 }
925
926 // y + height
927 if (y_healthy && height_healthy) {
928 const float boundary = viewport.y + viewport.height;
929
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700930 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(object, "VUID-VkViewport-y-01233",
932 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
933 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
934 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700935 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600936 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700937 LogError(object, "VUID-VkViewport-y-01777",
938 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
939 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
940 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100941 }
942 }
943
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700944 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100945 // minDepth
946 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700947 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600948
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
950 "[0.0, 1.0] range.",
951 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100952 }
953
954 // maxDepth
955 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700956 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600957
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700958 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
959 "[0.0, 1.0] range.",
960 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100961 }
962 }
963
964 return skip;
965}
966
Dave Houlton142c4cb2018-10-17 15:04:41 -0600967struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500968 VkShadingRatePaletteEntryNV shadingRate;
969 uint32_t width;
970 uint32_t height;
971};
972
973// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600974static SampleOrderInfo sampleOrderInfos[] = {
975 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
976 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
977 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
978 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
979 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
980 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500981};
982
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500983bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500984 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500985
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500986 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500987 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500988 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500989 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500990 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500991 break;
992 }
993 }
994
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500995 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700996 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
997 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
998 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500999 return skip;
1000 }
1001
Dave Houlton142c4cb2018-10-17 15:04:41 -06001002 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001003 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001004 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1005 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1006 ") must "
1007 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1008 "is set in framebufferNoAttachmentsSampleCounts.",
1009 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001010 }
1011
Jeff Bolz9af91c52018-09-01 21:53:57 -05001012 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1014 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1015 ") must "
1016 "be equal to the product of sampleCount (=%" PRIu32
1017 "), the fragment width for shadingRate "
1018 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1019 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001020 }
1021
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001022 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001023 skip |= LogError(
1024 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001025 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1026 ") must "
1027 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001028 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001029 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001030
1031 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001032 // the first width*height*sampleCount bits to all be set. Note: There is no
1033 // guarantee that 64 bits is enough, but practically it's unlikely for an
1034 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001035 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001036 uint64_t sampleLocationsMask = 0;
1037 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1038 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1039 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001040 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1041 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001042 }
1043 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001044 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1045 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001046 }
1047 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001048 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1049 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001050 }
1051 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1052 sampleLocationsMask |= 1ULL << idx;
1053 }
1054
1055 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1056 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001057 skip |= LogError(
1058 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001059 "The array pSampleLocations must contain exactly one entry for "
1060 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001061 }
1062
1063 return skip;
1064}
1065
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001066bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1067 uint32_t createInfoCount,
1068 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1069 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001070 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001071 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001072
1073 if (pCreateInfos != nullptr) {
1074 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001075 bool has_dynamic_viewport = false;
1076 bool has_dynamic_scissor = false;
1077 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001078 bool has_dynamic_depth_bias = false;
1079 bool has_dynamic_blend_constant = false;
1080 bool has_dynamic_depth_bounds = false;
1081 bool has_dynamic_stencil_compare = false;
1082 bool has_dynamic_stencil_write = false;
1083 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001084 bool has_dynamic_viewport_w_scaling_nv = false;
1085 bool has_dynamic_discard_rectangle_ext = false;
1086 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001087 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001088 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001089 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001090 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001091 if (pCreateInfos[i].pDynamicState != nullptr) {
1092 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1093 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1094 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001095 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1096 if (has_dynamic_viewport == true) {
1097 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1098 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1099 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1100 i);
1101 }
1102 has_dynamic_viewport = true;
1103 }
1104 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1105 if (has_dynamic_scissor == true) {
1106 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1107 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1108 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1109 i);
1110 }
1111 has_dynamic_scissor = true;
1112 }
1113 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1114 if (has_dynamic_line_width == true) {
1115 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1116 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1117 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1118 i);
1119 }
1120 has_dynamic_line_width = true;
1121 }
1122 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1123 if (has_dynamic_depth_bias == true) {
1124 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1125 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1126 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1127 i);
1128 }
1129 has_dynamic_depth_bias = true;
1130 }
1131 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1132 if (has_dynamic_blend_constant == true) {
1133 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1134 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1135 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1136 i);
1137 }
1138 has_dynamic_blend_constant = true;
1139 }
1140 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1141 if (has_dynamic_depth_bounds == true) {
1142 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1143 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1144 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1145 i);
1146 }
1147 has_dynamic_depth_bounds = true;
1148 }
1149 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1150 if (has_dynamic_stencil_compare == true) {
1151 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1152 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1153 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1154 i);
1155 }
1156 has_dynamic_stencil_compare = true;
1157 }
1158 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1159 if (has_dynamic_stencil_write == true) {
1160 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1161 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1162 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1163 i);
1164 }
1165 has_dynamic_stencil_write = true;
1166 }
1167 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1168 if (has_dynamic_stencil_reference == true) {
1169 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1170 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1171 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1172 i);
1173 }
1174 has_dynamic_stencil_reference = true;
1175 }
1176 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1177 if (has_dynamic_viewport_w_scaling_nv == true) {
1178 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1179 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1180 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1181 i);
1182 }
1183 has_dynamic_viewport_w_scaling_nv = true;
1184 }
1185 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1186 if (has_dynamic_discard_rectangle_ext == true) {
1187 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1188 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1189 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1190 i);
1191 }
1192 has_dynamic_discard_rectangle_ext = true;
1193 }
1194 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1195 if (has_dynamic_sample_locations_ext == true) {
1196 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1197 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1198 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1199 i);
1200 }
1201 has_dynamic_sample_locations_ext = true;
1202 }
1203 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1204 if (has_dynamic_exclusive_scissor_nv == true) {
1205 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1206 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1207 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1208 i);
1209 }
1210 has_dynamic_exclusive_scissor_nv = true;
1211 }
1212 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1213 if (has_dynamic_shading_rate_palette_nv == true) {
1214 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1215 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1216 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1217 i);
1218 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001219 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001220 }
1221 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1222 if (has_dynamic_viewport_course_sample_order_nv == true) {
1223 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1224 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1225 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1226 i);
1227 }
1228 has_dynamic_viewport_course_sample_order_nv = true;
1229 }
1230 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1231 if (has_dynamic_line_stipple == true) {
1232 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1233 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1234 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1235 i);
1236 }
1237 has_dynamic_line_stipple = true;
1238 }
Petr Kraus299ba622017-11-24 03:09:03 +01001239 }
1240 }
1241
Peter Chen85366392019-05-14 15:20:11 -04001242 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1243 if ((feedback_struct != nullptr) &&
1244 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001245 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1246 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1247 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1248 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1249 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001250 }
1251
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001252 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001253
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001254 // Collect active stages and other information
1255 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001256 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001257 bool has_eval = false;
1258 bool has_control = false;
1259 if (pCreateInfos[i].pStages != nullptr) {
1260 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1261 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1262
1263 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1264 has_control = true;
1265 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1266 has_eval = true;
1267 }
1268
1269 skip |= validate_string(
1270 "vkCreateGraphicsPipelines",
1271 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1272 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1273 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001274 }
1275
1276 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1277 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1278 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1279 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1280 pCreateInfos[i].pTessellationState,
1281 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1282 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1283
1284 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1285 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1286
1287 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1288 "VkPipelineTessellationDomainOriginStateCreateInfo",
1289 pCreateInfos[i].pTessellationState->pNext,
1290 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1291 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001292 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1293 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001294
1295 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1296 pCreateInfos[i].pTessellationState->flags,
1297 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1298 }
1299
1300 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1301 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1302 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1303 pCreateInfos[i].pInputAssemblyState,
1304 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1305 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1306
1307 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1308 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001309 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001310
1311 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1312 pCreateInfos[i].pInputAssemblyState->flags,
1313 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1314
1315 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1316 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1317 pCreateInfos[i].pInputAssemblyState->topology,
1318 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1319
1320 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1321 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1322 }
1323
1324 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001325 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001326
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001327 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001328 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1329 "vkCreateGraphicsPipelines: pararameter "
1330 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1331 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001332 }
1333
1334 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1335 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1336 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1337 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1338 pCreateInfos[i].pVertexInputState->pNext, 1,
1339 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001340 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1341 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001342 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1343 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001344 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001345 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1346 skip |=
1347 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1348 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1349 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1350 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1351 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1352
1353 skip |= validate_array(
1354 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1355 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1356 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1357 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1358
1359 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1360 for (uint32_t vertexBindingDescriptionIndex = 0;
1361 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1362 ++vertexBindingDescriptionIndex) {
1363 skip |= validate_ranged_enum(
1364 "vkCreateGraphicsPipelines",
1365 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1366 AllVkVertexInputRateEnums,
1367 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1368 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1369 }
1370 }
1371
1372 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1373 for (uint32_t vertexAttributeDescriptionIndex = 0;
1374 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1375 ++vertexAttributeDescriptionIndex) {
1376 skip |= validate_ranged_enum(
1377 "vkCreateGraphicsPipelines",
1378 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1379 AllVkFormatEnums,
1380 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1381 "VUID-VkVertexInputAttributeDescription-format-parameter");
1382 }
1383 }
1384
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001385 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001386 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1387 "vkCreateGraphicsPipelines: pararameter "
1388 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1389 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1390 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001391 }
1392
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001393 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001394 skip |=
1395 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1396 "vkCreateGraphicsPipelines: pararameter "
1397 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1398 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1399 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001400 }
1401
1402 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001403 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1404 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001405 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1406 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001407 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1408 "vkCreateGraphicsPipelines: parameter "
1409 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1410 "(%" PRIu32 ") is not distinct.",
1411 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001412 }
1413 vertex_bindings.insert(vertex_bind_desc.binding);
1414
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001415 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001416 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1417 "vkCreateGraphicsPipelines: parameter "
1418 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1419 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1420 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001421 }
1422
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001423 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001424 skip |=
1425 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1426 "vkCreateGraphicsPipelines: parameter "
1427 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1428 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1429 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001430 }
1431 }
1432
Peter Kohautc7d9d392018-07-15 00:34:07 +02001433 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001434 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1435 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001436 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1437 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001438 skip |= LogError(
1439 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001440 "vkCreateGraphicsPipelines: parameter "
1441 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1442 i, d, vertex_attrib_desc.location);
1443 }
1444 attribute_locations.insert(vertex_attrib_desc.location);
1445
1446 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1447 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001448 skip |= LogError(
1449 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001450 "vkCreateGraphicsPipelines: parameter "
1451 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1452 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1453 i, d, vertex_attrib_desc.binding, i);
1454 }
1455
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001456 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001457 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1458 "vkCreateGraphicsPipelines: parameter "
1459 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1460 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1461 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001462 }
1463
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001464 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001465 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1466 "vkCreateGraphicsPipelines: parameter "
1467 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1468 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1469 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001470 }
1471
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001472 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001473 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1474 "vkCreateGraphicsPipelines: parameter "
1475 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1476 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1477 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001478 }
1479 }
1480 }
1481
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001482 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1483 if (has_control && has_eval) {
1484 if (pCreateInfos[i].pTessellationState == nullptr) {
1485 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1486 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1487 "shader stage and a tessellation evaluation shader stage, "
1488 "pCreateInfos[%d].pTessellationState must not be NULL.",
1489 i, i);
1490 } else {
1491 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1492 skip |= validate_struct_pnext(
1493 "vkCreateGraphicsPipelines",
1494 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1495 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1496 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1497 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001498
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001499 skip |= validate_reserved_flags(
1500 "vkCreateGraphicsPipelines",
1501 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1502 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001503
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001504 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1505 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1506 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1507 "vkCreateGraphicsPipelines: invalid parameter "
1508 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1509 "should be >0 and <=%u.",
1510 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1511 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001512 }
1513 }
1514 }
1515
1516 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1517 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1518 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1519 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001520 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1521 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1522 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1523 "].pViewportState (=NULL) is not a valid pointer.",
1524 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001525 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001526 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1527
1528 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001529 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1530 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1531 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1532 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001533 }
1534
Petr Krausa6103552017-11-16 21:21:58 +01001535 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1536 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001537 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1538 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001539 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1540 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001541 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001542 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001543 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001544 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001545 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001546 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1547 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001548 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001549 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1550 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001551
1552 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001553 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001554 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001555 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001556
Dave Houlton142c4cb2018-10-17 15:04:41 -06001557 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1558 pCreateInfos[i].pViewportState->pNext);
1559 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1560 pCreateInfos[i].pViewportState->pNext);
1561 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1562 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001563 const auto vp_swizzle_struct =
1564 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001565 const auto vp_w_scaling_struct =
1566 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001567
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001568 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001569 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001570 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1571 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1572 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1573 ") is not 1.",
1574 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001575 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001576
Petr Krausa6103552017-11-16 21:21:58 +01001577 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001578 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1579 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1580 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1581 ") is not 1.",
1582 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001583 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001584
Dave Houlton142c4cb2018-10-17 15:04:41 -06001585 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1586 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001587 skip |= LogError(
1588 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1589 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1590 "disabled, but pCreateInfos[%" PRIu32
1591 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1592 ") is not 1.",
1593 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001594 }
1595
Jeff Bolz9af91c52018-09-01 21:53:57 -05001596 if (shading_rate_image_struct &&
1597 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001598 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1599 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1600 "disabled, but pCreateInfos[%" PRIu32
1601 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1602 ") is neither 0 nor 1.",
1603 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001604 }
1605
Petr Krausa6103552017-11-16 21:21:58 +01001606 } else { // multiViewport enabled
1607 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001608 skip |= LogError(
1609 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001610 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001611 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001612 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1613 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1614 "].pViewportState->viewportCount (=%" PRIu32
1615 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1616 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001617 }
Petr Krausa6103552017-11-16 21:21:58 +01001618
1619 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001620 skip |= LogError(
1621 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001622 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001623 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001624 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1625 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1626 "].pViewportState->scissorCount (=%" PRIu32
1627 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1628 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001629 }
1630 }
1631
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001632 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001633 skip |=
1634 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1635 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1636 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1637 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001638 }
1639
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001640 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001641 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1642 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1643 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1644 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1645 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001646 }
1647
Petr Krausa6103552017-11-16 21:21:58 +01001648 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001649 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1650 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1651 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1652 "].pViewportState->viewportCount (=%" PRIu32 ").",
1653 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001654 }
1655
Dave Houlton142c4cb2018-10-17 15:04:41 -06001656 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001657 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001658 skip |=
1659 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1660 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1661 ") must be zero or identical to pCreateInfos[%" PRIu32
1662 "].pViewportState->viewportCount (=%" PRIu32 ").",
1663 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001664 }
1665
Dave Houlton142c4cb2018-10-17 15:04:41 -06001666 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001667 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001668 skip |= LogError(
1669 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001670 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1671 "] "
1672 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1673 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1674 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001675 }
1676
Petr Krausa6103552017-11-16 21:21:58 +01001677 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001678 skip |= LogError(
1679 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001680 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1681 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001682 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1683 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001684 }
1685
1686 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001687 skip |= LogError(
1688 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001689 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1690 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001691 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1692 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001693 }
1694
Jeff Bolz3e71f782018-08-29 23:15:45 -05001695 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001696 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1697 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1698 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001699 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1700 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1701 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1702 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1703 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001704 }
1705
Jeff Bolz9af91c52018-09-01 21:53:57 -05001706 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001707 shading_rate_image_struct->viewportCount > 0 &&
1708 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001709 skip |= LogError(
1710 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001711 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001712 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1713 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001714 i, i);
1715 }
1716
Chris Mayer328d8212018-12-11 14:16:18 +01001717 if (vp_swizzle_struct) {
1718 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001719 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1720 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1721 " does "
1722 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1723 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001724 }
1725 }
1726
Petr Krausb3fcdb42018-01-09 22:09:09 +01001727 // validate the VkViewports
1728 if (!has_dynamic_viewport && viewport_state.pViewports) {
1729 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1730 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001731 const char *fn_name = "vkCreateGraphicsPipelines";
1732 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1733 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1734 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001735 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001736 }
1737 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001738
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001739 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
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_VIEWPORT_W_SCALING_NV, but "
1743 "VK_NV_clip_space_w_scaling extension is not enabled.",
1744 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001745 }
1746
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001747 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
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_DISCARD_RECTANGLE_EXT, but "
1751 "VK_EXT_discard_rectangles extension is not enabled.",
1752 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001753 }
1754
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001755 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001756 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1757 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1758 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1759 "VK_EXT_sample_locations extension is not enabled.",
1760 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001761 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001762
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001763 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001764 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1765 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1766 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1767 "VK_NV_scissor_exclusive extension is not enabled.",
1768 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001769 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001770
1771 if (coarse_sample_order_struct &&
1772 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1773 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001774 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1775 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1776 "] "
1777 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1778 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1779 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001780 }
1781
1782 if (coarse_sample_order_struct) {
1783 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001784 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001785 }
1786 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001787
1788 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1789 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001790 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1791 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1792 "] "
1793 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1794 ") "
1795 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1796 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001797 }
1798 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001799 skip |= LogError(
1800 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001801 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1802 "] "
1803 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1804 i);
1805 }
1806 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001807 }
1808
1809 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001810 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1811 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1812 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1813 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001814 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001815 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1816 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1817 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001818 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001819 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001820 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001821 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001822 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001823 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001824 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001825 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1826 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001827
1828 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001829 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001830 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001831 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001832
1833 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001834 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1836 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1837
1838 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001839 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001840 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1841 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001842 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001843 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001844
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001845 skip |= validate_flags(
1846 "vkCreateGraphicsPipelines",
1847 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1848 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001849 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001850
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001851 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001852 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001853 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1854 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1855
1856 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001857 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001858 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1859 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1860
1861 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001862 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1863 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1864 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1865 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001866 }
John Zulauf7acac592017-11-06 11:15:53 -07001867 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001868 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001869 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1870 "vkCreateGraphicsPipelines(): parameter "
1871 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1872 i);
John Zulauf7acac592017-11-06 11:15:53 -07001873 }
1874 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1875 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1876 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 skip |= LogError(
1878 device,
1879
Dave Houlton413a6782018-05-22 13:01:54 -06001880 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001881 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001882 }
1883 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001884
1885 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1886 pCreateInfos[i].pRasterizationState->pNext);
1887
1888 if (line_state) {
1889 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1890 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1891 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1892 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001893 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1894 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1895 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1896 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001897 }
1898 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1899 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1901 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1902 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1903 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001904 }
1905 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1906 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001907 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1908 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1909 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1910 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001911 }
1912 }
1913 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1914 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1915 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001916 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1917 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1918 "range [1,256].",
1919 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001920 }
1921 }
1922 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001923 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001924 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1925 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001926 skip |=
1927 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1928 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1929 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1930 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001931 }
1932 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1933 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001934 skip |=
1935 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1936 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1937 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1938 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001939 }
1940 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1941 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001942 skip |=
1943 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1944 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1945 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1946 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001947 }
1948 if (line_state->stippledLineEnable) {
1949 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1950 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001951 skip |=
1952 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1953 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1954 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1955 "stippledRectangularLines feature.",
1956 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001957 }
1958 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1959 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001960 skip |=
1961 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1962 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1963 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1964 "stippledBresenhamLines feature.",
1965 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001966 }
1967 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1968 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001969 skip |=
1970 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1971 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1972 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1973 "stippledSmoothLines feature.",
1974 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001975 }
1976 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1977 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001978 skip |=
1979 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1980 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1981 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1982 "stippledRectangularLines and strictLines features.",
1983 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001984 }
1985 }
1986 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 }
1988
Petr Krause91f7a12017-12-14 20:57:36 +01001989 bool uses_color_attachment = false;
1990 bool uses_depthstencil_attachment = false;
1991 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001992 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1994 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001995 const auto &subpasses_uses = subpasses_uses_it->second;
1996 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1997 uses_color_attachment = true;
1998 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1999 uses_depthstencil_attachment = true;
2000 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002001 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002002 }
2003
2004 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002005 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002006 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002007 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002008 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002009 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002010
2011 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002012 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002013 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002014 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
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->depthTestEnable", ParameterName::IndexVector{i}),
2019 pCreateInfos[i].pDepthStencilState->depthTestEnable);
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->depthWriteEnable", ParameterName::IndexVector{i}),
2024 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
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->depthCompareOp", ParameterName::IndexVector{i}),
2029 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002030 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002031
2032 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002033 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002034 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2035 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2036
2037 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002038 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002039 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2040 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2041
2042 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002043 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002044 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2045 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002046 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002047
2048 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002049 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002050 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2051 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002052 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002053
2054 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002055 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002056 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2057 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002058 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002059
2060 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002061 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002062 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2063 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002064 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065
2066 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002067 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2069 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002070 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002071
2072 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002073 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002074 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2075 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002076 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002077
2078 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002079 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002080 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2081 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002082 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002083
2084 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002085 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002086 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2087 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002088 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089
2090 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002091 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2092 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2093 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2094 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002095 }
2096 }
2097
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002098 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2099 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2100
Petr Krause91f7a12017-12-14 20:57:36 +01002101 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002102 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2103 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2104 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2105 pCreateInfos[i].pColorBlendState,
2106 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2107 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2108
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002109 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002110 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002111 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2112 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2113 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002114 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002115 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2116 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002117
2118 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002119 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002120 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002121 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002122
2123 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002124 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002125 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2126 pCreateInfos[i].pColorBlendState->logicOpEnable);
2127
2128 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002129 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002130 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2131 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002132 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002133 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002134
2135 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2136 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2137 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002138 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002139 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2140 ParameterName::IndexVector{i, attachmentIndex}),
2141 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2142
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].srcColorBlendFactor",
2146 ParameterName::IndexVector{i, attachmentIndex}),
2147 "VkBlendFactor", AllVkBlendFactorEnums,
2148 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002149 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-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].dstColorBlendFactor",
2154 ParameterName::IndexVector{i, attachmentIndex}),
2155 "VkBlendFactor", AllVkBlendFactorEnums,
2156 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002157 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-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].colorBlendOp",
2162 ParameterName::IndexVector{i, attachmentIndex}),
2163 "VkBlendOp", AllVkBlendOpEnums,
2164 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002165 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-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].srcAlphaBlendFactor",
2170 ParameterName::IndexVector{i, attachmentIndex}),
2171 "VkBlendFactor", AllVkBlendFactorEnums,
2172 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002173 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002174
2175 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002176 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002177 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2178 ParameterName::IndexVector{i, attachmentIndex}),
2179 "VkBlendFactor", AllVkBlendFactorEnums,
2180 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002181 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002182
2183 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002185 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2186 ParameterName::IndexVector{i, attachmentIndex}),
2187 "VkBlendOp", AllVkBlendOpEnums,
2188 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002189 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002190
2191 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002192 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002193 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2194 ParameterName::IndexVector{i, attachmentIndex}),
2195 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2196 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002197 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198 }
2199 }
2200
2201 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2203 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2204 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2205 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002206 }
2207
2208 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2209 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2210 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002211 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002212 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002213 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2214 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002215 }
2216 }
2217 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002218
Petr Kraus9752aae2017-11-24 03:05:50 +01002219 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2220 if (pCreateInfos[i].basePipelineIndex != -1) {
2221 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002222 skip |=
2223 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2224 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2225 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2226 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002227 }
2228 }
2229
Petr Kraus9752aae2017-11-24 03:05:50 +01002230 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2231 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002232 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2233 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2234 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2235 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002236 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002237 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002238 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2240 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2241 "index into the pCreateInfos array, of size %d.",
2242 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002243 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244 }
2245 }
2246
Petr Kraus9752aae2017-11-24 03:05:50 +01002247 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002248 if (!device_extensions.vk_nv_fill_rectangle) {
2249 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2250 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002251 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2252 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2253 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2254 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002255 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2256 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002257 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2258 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2259 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2260 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002261 }
2262 } else {
2263 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2264 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2265 (physical_device_features.fillModeNonSolid == false)) {
2266 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002267 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2268 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2269 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2270 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002271 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002272 }
Petr Kraus299ba622017-11-24 03:09:03 +01002273
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002274 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002275 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002276 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2277 "The line width state is static (pCreateInfos[%" PRIu32
2278 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2279 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2280 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2281 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002282 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 }
2285 }
2286
2287 return skip;
2288}
2289
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002290bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2291 uint32_t createInfoCount,
2292 const VkComputePipelineCreateInfo *pCreateInfos,
2293 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002294 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002295 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002297 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002299 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002300 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2301 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002302 skip |=
2303 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2304 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2305 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2306 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002307 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002308
2309 // Make sure compute stage is selected
2310 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002311 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2312 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2313 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002314 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002316 return skip;
2317}
2318
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002319bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002320 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002322
2323 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002324 const auto &features = physical_device_features;
2325 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002326
John Zulauf71968502017-10-26 13:51:15 -06002327 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2328 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2330 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2331 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2332 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002333 }
2334
2335 // Anistropy cannot be enabled in sampler unless enabled as a feature
2336 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002337 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2338 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2339 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002340 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002341 }
John Zulauf71968502017-10-26 13:51:15 -06002342
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002343 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2344 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2346 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2347 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2348 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002349 }
2350 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002351 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2352 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2353 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2354 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002355 }
2356 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002357 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2358 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2359 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2360 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002361 }
2362 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2363 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2364 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2365 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2367 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2368 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2369 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2370 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2371 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002372 }
2373 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2375 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2376 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002377 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002378 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002379 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2380 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2381 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002382 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 }
2384
2385 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2386 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002387 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2388 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002389 }
2390
2391 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2392 // valid VkBorderColor value
2393 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2394 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2395 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002396 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2397 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002398 }
2399
2400 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2401 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002402 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002403 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2404 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2405 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002406 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002407 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2408 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2409 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002410 }
John Zulauf275805c2017-10-26 15:34:49 -06002411
2412 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002413 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002414 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2415 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002416 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2417 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2418 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002419 }
2420 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002421
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002422 // Check for valid Lod range
2423 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002424 skip |=
2425 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2426 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002427 }
2428
2429 // Check mipLodBias to device limit
2430 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002431 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2432 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2433 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002434 }
2435
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002436 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2437 if (sampler_conversion != nullptr) {
2438 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2439 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2440 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2441 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002442 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002443 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002444 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2445 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2446 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2447 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2448 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2449 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2450 }
2451 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002452 }
2453
2454 return skip;
2455}
2456
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002457bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2458 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2459 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002460 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462
2463 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2464 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2465 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2466 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002467 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2468 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2469 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2470 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2471 ++descriptor_index) {
2472 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002473 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002474 "vkCreateDescriptorSetLayout: required parameter "
2475 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2476 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 }
2478 }
2479 }
2480
2481 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2482 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2483 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002484 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2485 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2486 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2487 "values.",
2488 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002489 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002490
2491 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2492 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2493 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2494 skip |=
2495 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2496 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2497 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2498 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2499 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2500 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002501 }
2502 }
2503 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002504 return skip;
2505}
2506
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002507bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2508 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002509 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002510 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2511 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2512 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002513 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2514 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515}
2516
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002517bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2518 const VkWriteDescriptorSet *pDescriptorWrites,
2519 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002521
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522 if (pDescriptorWrites != NULL) {
2523 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2524 // descriptorCount must be greater than 0
2525 if (pDescriptorWrites[i].descriptorCount == 0) {
2526 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002527 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2528 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529 }
2530
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002531 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2532 if (validateDstSet) {
2533 // dstSet must be a valid VkDescriptorSet handle
2534 skip |= validate_required_handle(vkCallingFunction,
2535 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2536 pDescriptorWrites[i].dstSet);
2537 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538
2539 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2540 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2541 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2542 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2543 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2544 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2545 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2546 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2547 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002548 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2549 "%s(): if pDescriptorWrites[%d].descriptorType is "
2550 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2551 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2552 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2553 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2555 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2556 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2557 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2558 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2559 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002560 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2562 ParameterName::IndexVector{i, descriptor_index}),
2563 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002564 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2566 ParameterName::IndexVector{i, descriptor_index}),
2567 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002568 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002569 }
2570 }
2571 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2572 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2573 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2574 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2575 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2576 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2577 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2578 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2580 "%s(): if pDescriptorWrites[%d].descriptorType is "
2581 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2582 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2583 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2584 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002585 } else {
2586 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002587 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002588 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2589 ParameterName::IndexVector{i, descriptorIndex}),
2590 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2591 }
2592 }
2593 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2594 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2595 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2596 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2597 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002598 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2599 "%s(): if pDescriptorWrites[%d].descriptorType is "
2600 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2601 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2602 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603 } else {
2604 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2605 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002606 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2608 ParameterName::IndexVector{i, descriptor_index}),
2609 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2610 }
2611 }
2612 }
2613
2614 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2615 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2618 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2619 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002620 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002621 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2622 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2623 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2624 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002625 }
2626 }
2627 }
2628 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2629 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002630 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2632 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2633 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002634 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002635 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2636 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2637 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2638 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639 }
2640 }
2641 }
2642 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002643 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2644 // or VkWriteDescriptorSetInlineUniformBlockEX
2645 if (pDescriptorWrites[i].pNext) {
2646 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2647 const auto *pNext_struct =
2648 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2649 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2650 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2651 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2652 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2653 "accelerationStructureCount %d member equals descriptorCount %d.",
2654 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2655 pDescriptorWrites[i].descriptorCount);
2656 }
2657 // further checks only if we have right structtype
2658 if (pNext_struct) {
2659 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2660 skip |= LogError(
2661 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2662 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2663 ".",
2664 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2665 }
2666 if (pNext_struct->accelerationStructureCount == 0) {
2667 skip |= LogError(
2668 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2669 "%s(): accelerationStructureCount must be greater than 0 .");
2670 }
2671 }
2672 }
2673 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002674 }
2675 }
2676 return skip;
2677}
2678
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002679bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2680 const VkWriteDescriptorSet *pDescriptorWrites,
2681 uint32_t descriptorCopyCount,
2682 const VkCopyDescriptorSet *pDescriptorCopies) const {
2683 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2684}
2685
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002686bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002687 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002688 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002689 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2690}
2691
2692bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002693 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002694 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002695 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2696}
2697
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002698bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2699 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002700 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002701 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002702
2703 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2704 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2705 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002706 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2707 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 return skip;
2709}
2710
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002711bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002712 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002714
2715 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2716 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2718
Petr Krause7bb9e82019-08-11 21:34:43 +02002719 // Implicit VUs
2720 // validate only sType here; pointer has to be validated in core_validation
2721 const bool kNotRequired = false;
2722 const char *kNoVUID = nullptr;
2723 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2724 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2725 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002726
Petr Krause7bb9e82019-08-11 21:34:43 +02002727 if (pInfo) {
2728 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2729 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2730 skip |= validate_struct_pnext(
2731 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2732 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002733 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2734 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735
Petr Krause7bb9e82019-08-11 21:34:43 +02002736 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737
Petr Krause7bb9e82019-08-11 21:34:43 +02002738 // Explicit VUs
2739 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002740 skip |= LogError(
2741 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002742 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2743 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002745
2746 if (physical_device_features.inheritedQueries) {
2747 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002748 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002749 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002750 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002751 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002752 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002753 }
2754
2755 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002756 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002757 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002758 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002759 } else { // !pipelineStatisticsQuery
2760 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2761 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002762 }
Petr Kraus139757b2019-08-15 17:19:33 +02002763
2764 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2765 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002766 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002767 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2768 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002769 skip |= LogError(
2770 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002771 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2772 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2773 }
2774 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 }
2776
2777 return skip;
2778}
2779
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002780bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002781 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002784 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002785 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002786 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2787 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2788 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002789 }
2790 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002791 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2792 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2793 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002794 }
2795 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002796 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002797 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2799 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2800 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2801 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002804
2805 if (pViewports) {
2806 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2807 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002808 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002809 skip |= manual_PreCallValidateViewport(
2810 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002811 }
2812 }
2813
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 return skip;
2815}
2816
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002817bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002818 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002820
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002821 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2824 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2825 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002826 }
2827 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002828 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2829 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2830 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002831 }
2832 } else { // multiViewport enabled
2833 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002834 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2836 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2837 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2838 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 }
2840 }
2841
Petr Kraus6260f0a2018-02-27 21:15:55 +01002842 if (pScissors) {
2843 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2844 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845
Petr Kraus6260f0a2018-02-27 21:15:55 +01002846 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002847 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2848 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2849 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002850 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851
Petr Kraus6260f0a2018-02-27 21:15:55 +01002852 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2854 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2855 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002856 }
2857
2858 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2859 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2861 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2862 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2863 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002864 }
2865
2866 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2867 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002868 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2869 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2870 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2871 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002872 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002873 }
2874 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002875
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 return skip;
2877}
2878
Jeff Bolz5c801d12019-10-09 10:38:45 -05002879bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002880 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002881
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002883 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2884 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002885 }
2886
2887 return skip;
2888}
2889
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002890bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002891 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893 if (vertexCount == 0) {
2894 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2895 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002896 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898
2899 if (instanceCount == 0) {
2900 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2901 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002902 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002903 }
2904 return skip;
2905}
2906
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002907bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002908 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002911 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002912 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2913 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002914 }
2915 return skip;
2916}
2917
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002918bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002919 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002921 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002922 skip |=
2923 LogError(device, kVUID_PVError_DeviceFeature,
2924 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925 }
2926 return skip;
2927}
2928
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002929bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2930 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002931 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002932 bool skip = false;
2933 for (uint32_t rect = 0; rect < rectCount; rect++) {
2934 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002935 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2936 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002937 }
sfricke-samsung10867682020-04-25 02:20:39 -07002938 if (pRects[rect].rect.extent.width == 0) {
2939 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
2940 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
2941 }
2942 if (pRects[rect].rect.extent.height == 0) {
2943 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
2944 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
2945 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002946 }
2947 return skip;
2948}
2949
Andrew Fobel3abeb992020-01-20 16:33:22 -05002950bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2951 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2952 VkImageFormatProperties2 *pImageFormatProperties,
2953 const char *apiName) const {
2954 bool skip = false;
2955
2956 if (pImageFormatInfo != nullptr) {
2957 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2958 if (image_stencil_struct != nullptr) {
2959 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2960 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2961 // No flags other than the legal attachment bits may be set
2962 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2963 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002964 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2965 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2966 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2967 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2968 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002969 }
2970 }
2971 }
2972 }
2973
2974 return skip;
2975}
2976
2977bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2978 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2979 VkImageFormatProperties2 *pImageFormatProperties) const {
2980 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2981 "vkGetPhysicalDeviceImageFormatProperties2");
2982}
2983
2984bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2985 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2986 VkImageFormatProperties2 *pImageFormatProperties) const {
2987 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2988 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2989}
2990
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002991bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2992 VkImageLayout srcImageLayout, VkImage dstImage,
2993 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002994 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996
Dave Houltonf5217612018-02-02 16:18:52 -07002997 VkImageAspectFlags legal_aspect_flags =
2998 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 -07002999 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003000 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3001 }
3002
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003004 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 skip |= LogError(
3006 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003007 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003008 }
Dave Houltonf5217612018-02-02 16:18:52 -07003009 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003010 skip |= LogError(
3011 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003012 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 }
3014 }
3015 return skip;
3016}
3017
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003018bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3019 VkImageLayout srcImageLayout, VkImage dstImage,
3020 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003021 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003022 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003023
Dave Houltonf5217612018-02-02 16:18:52 -07003024 VkImageAspectFlags legal_aspect_flags =
3025 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 -07003026 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003027 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3028 }
3029
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003031 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 skip |= LogError(
3033 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003034 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3035 }
Dave Houltonf5217612018-02-02 16:18:52 -07003036 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 skip |= LogError(
3038 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003039 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3040 }
3041 }
3042 return skip;
3043}
3044
sfricke-samsung3999ef62020-02-09 17:05:59 -08003045bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3046 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3047 bool skip = false;
3048
3049 if (pRegions != nullptr) {
3050 for (uint32_t i = 0; i < regionCount; i++) {
3051 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003052 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3053 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003054 }
3055 }
3056 }
3057 return skip;
3058}
3059
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003060bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3061 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003062 uint32_t regionCount,
3063 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065
Dave Houltonf5217612018-02-02 16:18:52 -07003066 VkImageAspectFlags legal_aspect_flags =
3067 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 -07003068 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003069 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3070 }
3071
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003073 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3075 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3076 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003077 }
3078 }
3079 return skip;
3080}
3081
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003082bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3083 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003084 uint32_t regionCount,
3085 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087
Dave Houltonf5217612018-02-02 16:18:52 -07003088 VkImageAspectFlags legal_aspect_flags =
3089 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 -07003090 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003091 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3092 }
3093
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003094 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003095 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003096 skip |= LogError(
3097 device, kVUID_PVError_UnrecognizedValue,
3098 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3099 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100 }
3101 }
3102 return skip;
3103}
3104
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003105bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003106 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3107 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003108 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109
3110 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003111 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3112 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3113 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003114 }
3115
3116 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003117 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3118 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3119 "), must be greater than zero and less than or equal to 65536.",
3120 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003122 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3123 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3124 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125 }
3126 return skip;
3127}
3128
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003129bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003130 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132
3133 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003134 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3135 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3136 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 }
3138
3139 if (size != VK_WHOLE_SIZE) {
3140 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003141 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3143 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003145 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3146 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 }
3148 }
3149 return skip;
3150}
3151
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003152bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003153 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003154 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156
3157 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3159 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3160 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3161 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003162 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3163 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3164 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 }
3166
3167 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3168 // queueFamilyIndexCount uint32_t values
3169 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003170 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3171 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3172 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3173 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003174 }
3175 }
3176
Dave Houlton413a6782018-05-22 13:01:54 -06003177 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003178 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003179 }
3180
3181 return skip;
3182}
3183
Jeff Bolz5c801d12019-10-09 10:38:45 -05003184bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003185 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003186
3187 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003188 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3189 if (present_regions) {
3190 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003191 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003192 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3193 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003194 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3195 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3196 "extension swapchainCount is %i. These values must be equal.",
3197 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003198 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003199 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003200 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3201 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003202 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3203 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3204 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003205 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003206 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003207 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003208 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 }
3211 }
3212
3213 return skip;
3214}
3215
3216#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003217bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3218 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3219 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003220 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221 bool skip = false;
3222
3223 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003224 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3225 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003226 }
3227
3228 return skip;
3229}
3230#endif // VK_USE_PLATFORM_WIN32_KHR
3231
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003232bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003233 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003234 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003235 bool skip = false;
3236
3237 if (pCreateInfo) {
3238 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003239 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3240 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003241 }
3242
3243 if (pCreateInfo->pPoolSizes) {
3244 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3245 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003246 skip |= LogError(
3247 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003248 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003249 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003250 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3251 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003252 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3253 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3254 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3255 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3256 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003257 }
Petr Krausc8655be2017-09-27 18:56:51 +02003258 }
3259 }
3260 }
3261
3262 return skip;
3263}
3264
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003265bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003266 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003267 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003268
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003269 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003270 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003271 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3272 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3273 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003274 }
3275
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003276 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003277 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003278 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3279 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3280 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003281 }
3282
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003283 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003284 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3286 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3287 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003288 }
3289
3290 return skip;
3291}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003292
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003293bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003294 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003295 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003296
3297 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003298 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3299 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003300 }
3301 return skip;
3302}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003303
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003304bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3305 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003306 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003307 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003308
3309 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003310 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003311 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3313 "vkCmdDispatch(): baseGroupX (%" PRIu32
3314 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3315 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003316 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3318 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3319 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3320 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003321 }
3322
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003323 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003324 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003325 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3326 "vkCmdDispatch(): baseGroupY (%" PRIu32
3327 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3328 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003329 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003330 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3331 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3332 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3333 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003334 }
3335
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003336 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003337 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003338 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3339 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3340 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3341 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003342 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003343 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3344 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3345 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3346 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003347 }
3348
3349 return skip;
3350}
3351
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003352bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3353 VkPipelineBindPoint pipelineBindPoint,
3354 VkPipelineLayout layout, uint32_t set,
3355 uint32_t descriptorWriteCount,
3356 const VkWriteDescriptorSet *pDescriptorWrites) const {
3357 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3358}
3359
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003360bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3361 uint32_t firstExclusiveScissor,
3362 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003363 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003364 bool skip = false;
3365
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003366 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003367 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003368 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003369 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3370 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3371 ") is not 0.",
3372 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003373 }
3374 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003375 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003376 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3377 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3378 ") is not 1.",
3379 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003380 }
3381 } else { // multiViewport enabled
3382 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003383 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003384 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3385 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3386 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3387 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003388 }
3389 }
3390
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003391 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003392 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3393 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3394 ") must be less than maxViewports (=%" PRIu32 ").",
3395 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003396 }
3397
3398 if (pExclusiveScissors) {
3399 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3400 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3401
3402 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003403 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3404 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3405 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003406 }
3407
3408 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003409 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3410 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3411 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003412 }
3413
3414 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3415 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003416 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3417 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3418 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3419 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003420 }
3421
3422 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3423 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3425 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3426 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3427 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003428 }
3429 }
3430 }
3431
3432 return skip;
3433}
3434
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003435bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3436 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003437 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003438 bool skip = false;
3439 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003440 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3441 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3442 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003443 } else {
3444 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3445 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003446 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3447 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3448 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3449 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003450 }
3451 }
3452
3453 return skip;
3454}
3455
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003456bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3457 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003458 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003459 bool skip = false;
3460
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003461 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003462 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003463 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3465 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3466 ") is not 0.",
3467 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003468 }
3469 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003470 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003471 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3472 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3473 ") is not 1.",
3474 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003475 }
3476 }
3477
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003478 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3480 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3481 ") must be less than maxViewports (=%" PRIu32 ").",
3482 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003483 }
3484
3485 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003486 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003487 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3488 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3489 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3490 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003491 }
3492
3493 return skip;
3494}
3495
Jeff Bolz5c801d12019-10-09 10:38:45 -05003496bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3497 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3498 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003499 bool skip = false;
3500
Dave Houlton142c4cb2018-10-17 15:04:41 -06003501 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003502 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3503 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3504 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003505 }
3506
3507 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003508 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003509 }
3510
3511 return skip;
3512}
3513
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003514bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003515 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003516 bool skip = false;
3517
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003518 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 skip |= LogError(
3520 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003521 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3522 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003523 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003524 }
3525
3526 return skip;
3527}
3528
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003529bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3530 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003531 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003532 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003533 static const int condition_multiples = 0b0011;
3534 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003535 skip |= LogError(
3536 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003537 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003538 }
Lockee1c22882019-06-10 16:02:54 -06003539 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3541 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3542 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3543 stride);
Lockee1c22882019-06-10 16:02:54 -06003544 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003545 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003546 skip |= LogError(
3547 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3548 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003549 }
3550
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003551 return skip;
3552}
3553
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003554bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3555 VkDeviceSize offset, VkBuffer countBuffer,
3556 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003557 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003558 bool skip = false;
3559
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003560 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003561 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3562 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3563 "), is not a multiple of 4.",
3564 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003565 }
3566
3567 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003568 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3569 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3570 "), is not a multiple of 4.",
3571 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003572 }
3573
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003574 return skip;
3575}
3576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003577bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003578 const VkAllocationCallbacks *pAllocator,
3579 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003580 bool skip = false;
3581
3582 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3583 if (pCreateInfo != nullptr) {
3584 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3585 // VkQueryPipelineStatisticFlagBits values
3586 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3587 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003588 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3589 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3590 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3591 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003592 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003593 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003594 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003595}
3596
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003597bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3598 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003599 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003600 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3601 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003602}
3603
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003604void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003605 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3606 VkResult result) {
3607 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003608 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003609}
3610
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003611void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003612 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3613 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003614 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003615 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003616 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003617}
3618
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003619void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3620 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003621 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003622 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003623 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003624}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003625
3626bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003627 const VkAllocationCallbacks *pAllocator,
3628 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003629 bool skip = false;
3630
3631 if (pAllocateInfo) {
3632 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3633 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003634 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3635 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003636 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003637
3638 VkMemoryAllocateFlags flags = 0;
3639 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3640 if (flags_info) {
3641 flags = flags_info->flags;
3642 }
3643
3644 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3645 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3646 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003647 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3648 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3649 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003650 }
3651
3652#ifdef VK_USE_PLATFORM_WIN32_KHR
3653 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3654#endif
3655 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3656 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3657#ifdef VK_USE_PLATFORM_ANDROID_KHR
3658 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3659#endif
3660
3661 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 skip |= LogError(
3663 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003664 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3665 }
3666 if (
3667#ifdef VK_USE_PLATFORM_WIN32_KHR
3668 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3669#endif
3670 (import_memory_fd && import_memory_fd->handleType) ||
3671#ifdef VK_USE_PLATFORM_ANDROID_KHR
3672 (import_memory_ahb && import_memory_ahb->buffer) ||
3673#endif
3674 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003675 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3676 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003677 }
3678 }
3679
3680 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003681 VkBool32 capture_replay = false;
3682 VkBool32 buffer_device_address = false;
3683 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3684 if (vulkan_12_features) {
3685 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3686 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3687 } else {
3688 const auto *bda_features =
3689 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3690 if (bda_features) {
3691 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3692 buffer_device_address = bda_features->bufferDeviceAddress;
3693 }
3694 }
3695 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003696 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3697 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3698 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003699 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003700 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003701 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3702 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003703 }
3704 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003705 }
3706 return skip;
3707}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003708
Jason Macnak192fa0e2019-07-26 15:07:16 -07003709bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003710 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003711 bool skip = false;
3712
3713 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3714 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3715 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003717 } else {
3718 uint32_t vertex_component_size = 0;
3719 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3720 vertex_component_size = 4;
3721 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3722 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3723 vertex_component_size = 2;
3724 }
3725 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003727 }
3728 }
3729
3730 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3731 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003732 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003733 } else {
3734 uint32_t index_element_size = 0;
3735 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3736 index_element_size = 4;
3737 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3738 index_element_size = 2;
3739 }
3740 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003741 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003742 }
3743 }
3744 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3745 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003746 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003747 }
3748 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003750 }
3751 }
3752
3753 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003754 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003755 }
3756
3757 return skip;
3758}
3759
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003760bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3761 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003762 bool skip = false;
3763
3764 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003765 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003766 }
3767 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003768 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003769 }
3770
3771 return skip;
3772}
3773
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003774bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3775 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003776 bool skip = false;
3777 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003778 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003779 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003780 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003781 }
3782 return skip;
3783}
3784
3785bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003786 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003787 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003788 bool skip = false;
3789 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003790 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3791 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3792 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003793 }
3794 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003795 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3796 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3797 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003798 }
3799 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3800 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3802 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3803 "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 -07003804 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003805 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003806 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3807 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3808 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003809 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003810 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3812 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3813 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003814 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003815 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003816 uint64_t total_triangle_count = 0;
3817 for (uint32_t i = 0; i < info.geometryCount; i++) {
3818 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003819
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003821
Jason Macnak5c954952019-07-09 15:46:12 -07003822 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3823 continue;
3824 }
3825 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3826 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003827 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003828 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3829 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3830 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003831 }
3832 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003833 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3834 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3835 for (uint32_t i = 1; i < info.geometryCount; i++) {
3836 const VkGeometryNV &geometry = info.pGeometries[i];
3837 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003838 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003839 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3840 "info.pGeometries[0].geometryType.",
3841 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003842 }
3843 }
3844 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003845 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
3846 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
3847 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
3848 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
3849 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
3850 "or VK_GEOMETRY_TYPE_AABBS_NV.");
3851 }
3852 }
3853 skip |=
3854 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
3855 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07003856 return skip;
3857}
3858
Ricardo Garciaa4935972019-02-21 17:43:18 +01003859bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3860 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003861 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003862 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01003863 if (pCreateInfo) {
3864 if ((pCreateInfo->compactedSize != 0) &&
3865 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003866 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3867 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3868 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3869 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003870 }
Jason Macnak5c954952019-07-09 15:46:12 -07003871
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003872 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003873 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003874 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01003875 return skip;
3876}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003877
Jeff Bolz5c801d12019-10-09 10:38:45 -05003878bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3879 const VkAccelerationStructureInfoNV *pInfo,
3880 VkBuffer instanceData, VkDeviceSize instanceOffset,
3881 VkBool32 update, VkAccelerationStructureNV dst,
3882 VkAccelerationStructureNV src, VkBuffer scratch,
3883 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003884 bool skip = false;
3885
3886 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003887 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003888 }
3889
3890 return skip;
3891}
3892
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003893bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
3894 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3895 VkAccelerationStructureKHR *pAccelerationStructure) const {
3896 bool skip = false;
3897
3898 if (pCreateInfo) {
3899 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
3900 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3901 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3902 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
3903 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
3904 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3905 i);
3906 }
3907 }
3908
3909 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3910 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3911 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
3912 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
3913 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3914 i);
3915 }
3916 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003917 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
3918 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
3919 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
3920 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
3921 skip |= LogError(
3922 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
3923 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
3924 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
3925 }
3926 }
3927 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
3928 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
3929 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
3930 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3931 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
3932 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
3933 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
3934 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
3935 }
3936 }
3937 }
3938
3939 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
3940 pCreateInfo->maxGeometryCount != 1) {
3941 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
3942 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
3943 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003944 }
3945
3946 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
3947 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
3948 skip |= LogError(
3949 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
3950 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
3951 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
3952 }
3953
3954 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
3955 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
3956 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
3957 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
3958 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
3959 }
3960
3961 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
3962 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
3963 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
3964 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
3965 if (geometry_type != first_geometry_type) {
3966 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
3967 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
3968 "pGeometryInfos[0].geometryType.",
3969 i);
3970 }
3971 }
3972 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003973 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
3974 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
3975 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
3976 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
3977 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
3978 "maxGeometryCount %d.",
3979 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
3980 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003981 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003982 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
3983 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
3984 if (pCreateInfo->deviceAddress != 0) {
3985 skip |=
3986 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
3987 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
3988 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
3989 }
3990 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003991 return skip;
3992}
3993
Jason Macnak5c954952019-07-09 15:46:12 -07003994bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3995 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003996 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003997 bool skip = false;
3998 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4000 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004001 }
4002 return skip;
4003}
4004
Peter Chen85366392019-05-14 15:20:11 -04004005bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4006 uint32_t createInfoCount,
4007 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4008 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004009 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004010 bool skip = false;
4011
4012 for (uint32_t i = 0; i < createInfoCount; i++) {
4013 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4014 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4016 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4017 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4018 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4019 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004020 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004021
4022 const auto *pipeline_cache_contol_features =
4023 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4024 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4025 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4026 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4027 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4028 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4029 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4030 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4031 }
4032 }
4033
sourav parmarf4a78252020-04-10 13:04:21 -07004034 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4035 skip |=
4036 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4037 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4038 }
4039 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4040 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4041 skip |=
4042 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4043 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4044 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4045 }
4046 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4047 if (pCreateInfos[i].basePipelineIndex != -1) {
4048 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4049 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4050 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4051 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4052 "and pCreateInfos->basePipelineIndex is not -1.");
4053 }
4054 }
4055 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4056 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4057 skip |=
4058 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4059 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4060 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4061 "commands pCreateInfos parameter.");
4062 }
4063 } else {
4064 if (pCreateInfos[i].basePipelineIndex != -1) {
4065 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4066 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4067 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4068 }
4069 }
4070 }
4071 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4072 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4073 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4074 }
4075 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4076 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4077 "vkCreateRayTracingPipelinesNV: flags must not include "
4078 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4079 }
4080 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4081 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4082 "vkCreateRayTracingPipelinesNV: flags must not include "
4083 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4084 }
4085 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4086 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4087 "vkCreateRayTracingPipelinesNV: flags must not include "
4088 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4089 }
4090 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4091 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4092 "vkCreateRayTracingPipelinesNV: flags must not include "
4093 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4094 }
4095 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4096 skip |= LogError(
4097 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4098 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4099 }
4100 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4101 skip |= LogError(
4102 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4103 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4104 }
Peter Chen85366392019-05-14 15:20:11 -04004105 }
4106
4107 return skip;
4108}
4109
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004110bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4111 uint32_t createInfoCount,
4112 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4113 const VkAllocationCallbacks *pAllocator,
4114 VkPipeline *pPipelines) const {
4115 bool skip = false;
4116
4117 for (uint32_t i = 0; i < createInfoCount; i++) {
4118 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4119 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4120 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4121 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4122 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4123 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4124 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4125 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004126 const auto *pipeline_cache_contol_features =
4127 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4128 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4129 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4130 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4131 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4132 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4133 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4134 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4135 }
4136 }
4137 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4138 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4139 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4140 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4141 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4142 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4143 }
4144 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4145 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4146 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4147 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4148 }
4149 }
4150
sourav parmarf4a78252020-04-10 13:04:21 -07004151 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4152 skip |=
4153 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4154 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4155 }
4156 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4157 if (pCreateInfos[i].pLibraryInterface == NULL)
4158 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4159 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4160 }
4161 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4162 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4163 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4164 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4165 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4166 skip |= LogError(
4167 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4168 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4169 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4170 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4171 "must not be VK_SHADER_UNUSED_KHR");
4172 }
4173 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4174 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4175 skip |= LogError(
4176 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4177 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4178 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4179 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4180 "element must not be VK_SHADER_UNUSED_KHR");
4181 }
4182 }
4183 }
4184 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4185 if (pCreateInfos[i].basePipelineIndex != -1) {
4186 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4187 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4188 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4189 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4190 "and pCreateInfos->basePipelineIndex is not -1.");
4191 }
4192 }
4193 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4194 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4195 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4196 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4197 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4198 "commands pCreateInfos parameter %d.",
4199 pCreateInfos[i].basePipelineIndex, createInfoCount);
4200 }
4201 } else {
4202 if (pCreateInfos[i].basePipelineIndex != -1) {
4203 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4204 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4205 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4206 }
4207 }
4208 }
4209 if (pCreateInfos[i].libraries.libraryCount == 0) {
4210 if (pCreateInfos[i].stageCount == 0) {
4211 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4212 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4213 }
4214 if (pCreateInfos[i].groupCount == 0) {
4215 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4216 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4217 }
4218 } else {
4219 if (pCreateInfos[i].pLibraryInterface == NULL) {
4220 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4221 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4222 }
4223 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004224 }
4225
4226 return skip;
4227}
4228
Mike Schuchardt21638df2019-03-16 10:52:02 -07004229#ifdef VK_USE_PLATFORM_WIN32_KHR
4230bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4231 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004232 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004233 bool skip = false;
4234 if (!device_extensions.vk_khr_swapchain)
4235 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4236 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4237 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4238 if (!device_extensions.vk_khr_surface)
4239 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4240 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4241 skip |=
4242 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4243 if (!device_extensions.vk_ext_full_screen_exclusive)
4244 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4245 skip |= validate_struct_type(
4246 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4247 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4248 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4249 if (pSurfaceInfo != NULL) {
4250 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4251 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4252 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4253
4254 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4255 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4256 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4257 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004258 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4259 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004260
4261 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4262 }
4263 return skip;
4264}
4265#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004266
4267bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4268 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004269 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004270 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4271 bool skip = false;
4272 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4273 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4274 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4275 }
4276 return skip;
4277}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004278
4279bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004280 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004281 bool skip = false;
4282
4283 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004284 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4285 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004286 }
4287
4288 return skip;
4289}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004290
4291bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004292 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004293 bool skip = false;
4294
4295 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004296 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4297 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004298 }
4299
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004300 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06004301 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004302 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4303 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004304 }
4305
4306 return skip;
4307}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004308
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004309bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4310 uint32_t bindingCount, const VkBuffer *pBuffers,
4311 const VkDeviceSize *pOffsets) const {
4312 bool skip = false;
4313 if (firstBinding > device_limits.maxVertexInputBindings) {
4314 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4315 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4316 device_limits.maxVertexInputBindings);
4317 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4318 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4319 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4320 "maxVertexInputBindings (%u)",
4321 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4322 }
4323
4324 return skip;
4325}
4326
Mark Lobodzinski84988402019-09-11 15:27:30 -06004327bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004328 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004329 bool skip = false;
4330 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004331 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4332 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004333 }
4334 return skip;
4335}
4336
4337bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004338 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004339 bool skip = false;
4340 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004341 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4342 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004343 }
4344 return skip;
4345}
Petr Kraus3d720392019-11-13 02:52:39 +01004346
4347bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4348 VkSemaphore semaphore, VkFence fence,
4349 uint32_t *pImageIndex) const {
4350 bool skip = false;
4351
4352 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004353 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4354 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004355 }
4356
4357 return skip;
4358}
4359
4360bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4361 uint32_t *pImageIndex) const {
4362 bool skip = false;
4363
4364 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004365 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4366 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004367 }
4368
4369 return skip;
4370}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004371
4372bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4373 uint32_t firstInstance, VkBuffer counterBuffer,
4374 VkDeviceSize counterBufferOffset,
4375 uint32_t counterOffset, uint32_t vertexStride) const {
4376 bool skip = false;
4377
4378 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004379 skip |= LogError(
4380 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004381 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4382 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4383 }
4384
4385 return skip;
4386}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004387
4388bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4389 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4390 const VkAllocationCallbacks *pAllocator,
4391 VkSamplerYcbcrConversion *pYcbcrConversion,
4392 const char *apiName) const {
4393 bool skip = false;
4394
4395 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004396 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004397 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4399 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004400 }
4401 return skip;
4402}
4403
4404bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4405 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4406 const VkAllocationCallbacks *pAllocator,
4407 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4408 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4409 "vkCreateSamplerYcbcrConversion");
4410}
4411
4412bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4413 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4414 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4415 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4416 "vkCreateSamplerYcbcrConversionKHR");
4417}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004418
4419bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4420 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4421 bool skip = false;
4422 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4423 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4424
4425 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004426 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4427 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4428 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4429 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4430 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004431 }
4432 return skip;
4433}
sourav parmara96ab1a2020-04-25 16:28:23 -07004434
4435bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4436 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4437 bool skip = false;
4438 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4439 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4440 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4441 }
4442 return skip;
4443}
4444
4445bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4446 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4447 bool skip = false;
4448 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4449 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4450 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4451 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4452 }
4453 return skip;
4454}
4455
4456bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4457 const char *api_name) const {
4458 bool skip = false;
4459 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4460 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4461 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4462 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4463 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4464 api_name);
4465 }
4466 return skip;
4467}
4468
4469bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4470 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4471 bool skip = false;
4472 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
4473 return skip;
4474}
4475
4476bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4477 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4478 bool skip = false;
4479 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4480 return skip;
4481}
4482
4483bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
4484 const char *api_name) const {
4485 bool skip = false;
4486 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
4487 skip |= LogError(device, "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
4488 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4489 }
4490 return skip;
4491}
4492
4493bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4494 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4495 bool skip = false;
4496 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()");
4497 return skip;
4498}
4499bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4500 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4501 bool skip = false;
4502 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()");
4503 return skip;
4504}