blob: 12969e4bda9820adcdb1e5b76a4a5bfc06f2f703 [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
John Zulauf620755c2018-04-16 11:00:43 -060088template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070089ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
90 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -060091 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -070092 ExtEnabled state =
93 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -060094 return state;
95}
96
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070097bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -050098 const VkAllocationCallbacks *pAllocator,
99 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700100 bool skip = false;
101 // Note: From the spec--
102 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
103 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
104 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700105 ? pCreateInfo->pApplicationInfo->apiVersion
106 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700107 skip |= validate_api_version(local_api_version, api_version);
108 skip |= validate_instance_extensions(pCreateInfo);
109 return skip;
110}
111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700112void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700113 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
114 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700115 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
116 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700117 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700118 this->instance_extensions = instance_data->instance_extensions;
119}
120
121void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700122 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700123 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700124 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700125 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
126 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700128 // Parmeter validation also uses extension data
129 stateless_validation->device_extensions = this->device_extensions;
130
131 VkPhysicalDeviceProperties device_properties = {};
132 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600133 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700134 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
135
136 if (device_extensions.vk_nv_shading_rate_image) {
137 // Get the needed shading rate image limits
138 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
139 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600140 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700141 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
142 }
143
144 if (device_extensions.vk_nv_mesh_shader) {
145 // Get the needed mesh shader limits
146 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
147 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600148 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700149 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
150 }
151
Jason Macnak5c954952019-07-09 15:46:12 -0700152 if (device_extensions.vk_nv_ray_tracing) {
153 // Get the needed ray tracing limits
154 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
155 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
156 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500157 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
158 }
159
160 if (device_extensions.vk_khr_ray_tracing) {
161 // Get the needed ray tracing limits
162 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700166 }
167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700168 if (device_extensions.vk_ext_transform_feedback) {
169 // Get the needed transform feedback limits
170 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
171 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
172 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
173 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
174 }
175
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800176 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700178 // Save app-enabled features in this device's validation object
179 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
181 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
182 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
183 if (features2) {
184 tmp_features2_state.features = features2->features;
185 } else if (pCreateInfo->pEnabledFeatures) {
186 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200188 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200190 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700191 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200192 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700193}
194
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500196 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600197 bool skip = false;
198
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200199 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
200 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
201 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
205 skip |=
206 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
207 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
208 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
209 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600210 }
211
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700213 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
214 bool negative_viewport =
215 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200216 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700217 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
218 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
219 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600221 }
222
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600223 {
224 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
225 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
226 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700227 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
228 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
229 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600230 }
231 }
232
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
234 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600235 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
236 if (features2) {
237 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700238 skip |= LogError(device, kVUID_PVError_InvalidUsage,
239 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
240 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600241 }
242 }
243
Locke77fad1c2019-04-16 13:09:03 -0600244 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
245 if (features2) {
246 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700247 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
248 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
249 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600250 }
251 }
252
253 auto vertex_attribute_divisor_features =
254 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
255 if (vertex_attribute_divisor_features) {
256 bool extension_found = false;
257 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
258 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
259 VK_MAX_EXTENSION_NAME_SIZE)) {
260 extension_found = true;
261 break;
262 }
263 }
264 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700265 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
266 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
267 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600268 }
269 }
270
Tony-LunarG28017bc2020-01-23 14:40:25 -0700271 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
272 if (vulkan_11_features) {
273 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
274 while (current) {
275 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
276 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
277 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
278 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
279 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
280 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700281 skip |= LogError(
282 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700283 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
284 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
285 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
286 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
287 break;
288 }
289 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
290 }
291 }
292
293 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
294 if (vulkan_12_features) {
295 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
296 while (current) {
297 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
298 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
299 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
300 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
301 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
302 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
303 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
304 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
305 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
306 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
307 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
308 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
309 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700310 skip |= LogError(
311 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700312 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
313 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
314 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
315 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
316 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
317 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
318 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
319 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
320 break;
321 }
322 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
323 }
324 }
325
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600326 // Validate pCreateInfo->pQueueCreateInfos
327 if (pCreateInfo->pQueueCreateInfos) {
328 std::unordered_set<uint32_t> set;
329
330 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
331 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
332 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700333 skip |=
334 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
335 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
336 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
337 "index value.",
338 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600339 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700340 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
341 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
342 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
343 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600344 } else {
345 set.insert(requested_queue_family);
346 }
347
348 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
349 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
350 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
351 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700352 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
353 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
354 "] (=%f) is not between 0 and 1 (inclusive).",
355 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600356 }
357 }
358 }
359 }
360 }
361
362 return skip;
363}
364
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500365bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700366 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700367 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
368 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
369 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600370 }
371
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700372 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600373}
374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700375bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500376 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100377 bool skip = false;
378
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600379 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700380 skip |=
381 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600382
383 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
384 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
385 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
386 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700387 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
388 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
389 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600390 }
391
392 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
393 // queueFamilyIndexCount uint32_t values
394 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700395 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
396 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
397 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
398 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600399 }
400 }
401
402 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
403 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
404 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
405 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700406 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
407 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
408 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600409 }
410 }
411
412 return skip;
413}
414
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700415bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500416 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600417 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600418
419 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600420 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
421 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
422 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
423 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700424 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
425 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
426 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600427 }
428
429 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
430 // queueFamilyIndexCount uint32_t values
431 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700432 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
433 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
434 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
435 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600436 }
437 }
438
Dave Houlton413a6782018-05-22 13:01:54 -0600439 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700440 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600441 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700442 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600443 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700444 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600445
Dave Houlton413a6782018-05-22 13:01:54 -0600446 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700447 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600448 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600450
Dave Houlton130c0212018-01-29 13:39:56 -0700451 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700452 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
453 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700454 skip |= LogError(
455 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600456 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
457 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700458 }
459
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600460 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100461 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
462 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
464 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
465 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466 }
467
468 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100469 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
470 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700471 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
472 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
473 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
474 ") are not equal.",
475 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100476 }
477
478 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
480 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
481 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
482 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100483 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 }
485
486 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(
488 device, "VUID-VkImageCreateInfo-imageType-00957",
489 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600490 }
491 }
492
Dave Houlton130c0212018-01-29 13:39:56 -0700493 // 3D image may have only 1 layer
494 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700495 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
496 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700497 }
498
499 // If multi-sample, validate type, usage, tiling and mip levels.
500 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
501 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600502 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700503 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
504 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700505 }
506
507 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
508 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
509 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
510 // At least one of the legal attachment bits must be set
511 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700512 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
513 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700514 }
515 // No flags other than the legal attachment bits may be set
516 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
517 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700518 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
519 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700520 }
521 }
522
Jeff Bolzef40fec2018-09-01 22:04:34 -0500523 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600524 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500525 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600526 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
527 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500528 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600529 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
531 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
532 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600533 }
534
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600535 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700536 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
537 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
538 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600539 }
540
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700541 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700542 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
543 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
544 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100545 }
546
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600547 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
548 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
549 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
550 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
552 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
553 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 }
555
556 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
557 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
558 // Linear tiling is unsupported
559 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700560 skip |= LogError(device, kVUID_PVError_InvalidUsage,
561 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
562 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600563 }
564
565 // Sparse 1D image isn't valid
566 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
568 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570
571 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700572 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700573 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
574 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
575 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600576 }
577
578 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700579 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700580 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
581 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
582 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600583 }
584
585 // Multi-sample 2D image when device doesn't support it
586 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700587 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700589 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
590 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
591 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700592 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600593 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
595 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
596 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700597 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600598 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
600 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
601 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700602 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600603 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
605 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
606 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600607 }
608 }
609 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500610
Jeff Bolz9af91c52018-09-01 21:53:57 -0500611 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
612 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700613 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
614 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
615 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500616 }
617 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700618 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
619 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
620 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500621 }
622 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
624 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
625 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500626 }
627 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500628
629 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600630 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700631 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
632 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
633 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500634 }
635
Dave Houlton142c4cb2018-10-17 15:04:41 -0600636 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
638 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
639 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
640 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500641 }
642
Dave Houlton142c4cb2018-10-17 15:04:41 -0600643 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
645 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
646 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
647 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500648 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600649 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700650 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
651 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
652 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
653 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500654 }
655 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500656
657 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
658 if (image_stencil_struct != nullptr) {
659 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
660 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
661 // No flags other than the legal attachment bits may be set
662 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
663 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700664 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
665 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
666 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
667 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500668 }
669 }
670
671 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
672 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
673 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
674 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
676 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
677 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
678 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500679 }
680
681 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700683 LogError(device, "VUID-VkImageCreateInfo-format-02537",
684 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
685 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
686 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500687 }
688 }
689
690 if (!physical_device_features.shaderStorageImageMultisample &&
691 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
692 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
693 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 LogError(device, "VUID-VkImageCreateInfo-format-02538",
695 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
696 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
697 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500698 }
699
700 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
701 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 skip |= LogError(
703 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500704 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
705 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
706 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
707 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
708 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(
710 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500711 "vkCreateImage(): Depth-stencil image in which usage does not include "
712 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
713 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
714 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
715 }
716
717 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
718 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700719 skip |= LogError(
720 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500721 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
722 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
723 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
724 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
725 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(
727 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500728 "vkCreateImage(): Depth-stencil image in which usage does not include "
729 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
730 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
731 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
732 }
733 }
734 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700735
736 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
737 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
738 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
739 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
740 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
741 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700742
743 if (device_extensions.vk_ext_image_drm_format_modifier) {
744 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
745 const auto drm_format_mod_explict =
746 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
747 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
748 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
749 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
750 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
751 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
752 "either VkImageDrmFormatModifierListCreateInfoEXT or "
753 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
754 }
755 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
756 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
757 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
758 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
759 "in the pNext chain");
760 }
761 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500763
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600764 return skip;
765}
766
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600767bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100769 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100770
771 // Note: for numerical correctness
772 // - float comparisons should expect NaN (comparison always false).
773 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
774
775 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700776 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100777 if (v1_f <= 0.0f) return true;
778
779 float intpart;
780 const float fract = modff(v1_f, &intpart);
781
782 assert(std::numeric_limits<float>::radix == 2);
783 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
784 if (intpart >= u32_max_plus1) return false;
785
786 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
787 if (v1_u32 < v2_u32)
788 return true;
789 else if (v1_u32 == v2_u32 && fract == 0.0f)
790 return true;
791 else
792 return false;
793 };
794
795 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
796 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
797 return (v1_f <= v2_f);
798 };
799
800 // width
801 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700802 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100803
804 if (!(viewport.width > 0.0f)) {
805 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
807 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100808 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
809 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 skip |= LogError(object, "VUID-VkViewport-width-01771",
811 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
812 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100813 } 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 -0700814 skip |= LogWarning(object, kVUID_PVError_NONE,
815 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
816 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
817 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100818 }
819
820 // height
821 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700822 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700823 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100824
825 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
826 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
828 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100829 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
830 height_healthy = false;
831
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 skip |= LogError(object, "VUID-VkViewport-height-01773",
833 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
834 ").",
835 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100836 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
837 height_healthy = false;
838
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700839 skip |= LogWarning(
840 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100841 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600842 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600843 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100844 }
845
846 // x
847 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700848 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100849 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700850 skip |= LogError(object, "VUID-VkViewport-x-01774",
851 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
852 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100853 }
854
855 // x + width
856 if (x_healthy && width_healthy) {
857 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700858 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(
860 object, "VUID-VkViewport-x-01232",
861 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
862 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
863 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100864 }
865 }
866
867 // y
868 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700869 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100870 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700871 skip |= LogError(object, "VUID-VkViewport-y-01775",
872 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
873 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700874 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100875 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(object, "VUID-VkViewport-y-01776",
877 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
878 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100879 }
880
881 // y + height
882 if (y_healthy && height_healthy) {
883 const float boundary = viewport.y + viewport.height;
884
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700885 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(object, "VUID-VkViewport-y-01233",
887 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
888 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
889 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700890 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600891 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700892 LogError(object, "VUID-VkViewport-y-01777",
893 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
894 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
895 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100896 }
897 }
898
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700899 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100900 // minDepth
901 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700902 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600903
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
905 "[0.0, 1.0] range.",
906 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100907 }
908
909 // maxDepth
910 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700911 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600912
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700913 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
914 "[0.0, 1.0] range.",
915 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100916 }
917 }
918
919 return skip;
920}
921
Dave Houlton142c4cb2018-10-17 15:04:41 -0600922struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500923 VkShadingRatePaletteEntryNV shadingRate;
924 uint32_t width;
925 uint32_t height;
926};
927
928// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600929static SampleOrderInfo sampleOrderInfos[] = {
930 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
931 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
932 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
933 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
934 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
935 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500936};
937
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500938bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500939 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500940
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500941 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500942 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500943 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500944 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500945 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500946 break;
947 }
948 }
949
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500950 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700951 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
952 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
953 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500954 return skip;
955 }
956
Dave Houlton142c4cb2018-10-17 15:04:41 -0600957 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700958 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700959 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
960 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
961 ") must "
962 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
963 "is set in framebufferNoAttachmentsSampleCounts.",
964 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500965 }
966
Jeff Bolz9af91c52018-09-01 21:53:57 -0500967 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700968 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
969 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
970 ") must "
971 "be equal to the product of sampleCount (=%" PRIu32
972 "), the fragment width for shadingRate "
973 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
974 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500975 }
976
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700977 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700978 skip |= LogError(
979 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600980 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
981 ") must "
982 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700983 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500984 }
Jeff Bolz9af91c52018-09-01 21:53:57 -0500985
986 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500987 // the first width*height*sampleCount bits to all be set. Note: There is no
988 // guarantee that 64 bits is enough, but practically it's unlikely for an
989 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700990 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500991 uint64_t sampleLocationsMask = 0;
992 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
993 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
994 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700995 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
996 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500997 }
998 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700999 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1000 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001001 }
1002 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001003 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1004 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001005 }
1006 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1007 sampleLocationsMask |= 1ULL << idx;
1008 }
1009
1010 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1011 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001012 skip |= LogError(
1013 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001014 "The array pSampleLocations must contain exactly one entry for "
1015 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001016 }
1017
1018 return skip;
1019}
1020
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001021bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1022 uint32_t createInfoCount,
1023 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1024 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001025 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001026 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001027
1028 if (pCreateInfos != nullptr) {
1029 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001030 bool has_dynamic_viewport = false;
1031 bool has_dynamic_scissor = false;
1032 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001033 bool has_dynamic_depth_bias = false;
1034 bool has_dynamic_blend_constant = false;
1035 bool has_dynamic_depth_bounds = false;
1036 bool has_dynamic_stencil_compare = false;
1037 bool has_dynamic_stencil_write = false;
1038 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001039 bool has_dynamic_viewport_w_scaling_nv = false;
1040 bool has_dynamic_discard_rectangle_ext = false;
1041 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001042 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001043 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001044 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001045 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001046 if (pCreateInfos[i].pDynamicState != nullptr) {
1047 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1048 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1049 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001050 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1051 if (has_dynamic_viewport == true) {
1052 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1053 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1054 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1055 i);
1056 }
1057 has_dynamic_viewport = true;
1058 }
1059 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1060 if (has_dynamic_scissor == true) {
1061 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1062 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1063 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1064 i);
1065 }
1066 has_dynamic_scissor = true;
1067 }
1068 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1069 if (has_dynamic_line_width == true) {
1070 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1071 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1072 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1073 i);
1074 }
1075 has_dynamic_line_width = true;
1076 }
1077 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1078 if (has_dynamic_depth_bias == true) {
1079 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1080 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1081 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1082 i);
1083 }
1084 has_dynamic_depth_bias = true;
1085 }
1086 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1087 if (has_dynamic_blend_constant == true) {
1088 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1089 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1090 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1091 i);
1092 }
1093 has_dynamic_blend_constant = true;
1094 }
1095 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1096 if (has_dynamic_depth_bounds == true) {
1097 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1098 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1099 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1100 i);
1101 }
1102 has_dynamic_depth_bounds = true;
1103 }
1104 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1105 if (has_dynamic_stencil_compare == true) {
1106 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1107 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1108 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1109 i);
1110 }
1111 has_dynamic_stencil_compare = true;
1112 }
1113 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1114 if (has_dynamic_stencil_write == true) {
1115 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1116 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1117 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1118 i);
1119 }
1120 has_dynamic_stencil_write = true;
1121 }
1122 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1123 if (has_dynamic_stencil_reference == true) {
1124 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1125 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1126 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1127 i);
1128 }
1129 has_dynamic_stencil_reference = true;
1130 }
1131 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1132 if (has_dynamic_viewport_w_scaling_nv == true) {
1133 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1134 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1135 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1136 i);
1137 }
1138 has_dynamic_viewport_w_scaling_nv = true;
1139 }
1140 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1141 if (has_dynamic_discard_rectangle_ext == true) {
1142 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1143 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1144 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1145 i);
1146 }
1147 has_dynamic_discard_rectangle_ext = true;
1148 }
1149 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1150 if (has_dynamic_sample_locations_ext == true) {
1151 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1152 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1153 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1154 i);
1155 }
1156 has_dynamic_sample_locations_ext = true;
1157 }
1158 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1159 if (has_dynamic_exclusive_scissor_nv == true) {
1160 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1161 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1162 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1163 i);
1164 }
1165 has_dynamic_exclusive_scissor_nv = true;
1166 }
1167 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1168 if (has_dynamic_shading_rate_palette_nv == true) {
1169 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1170 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1171 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1172 i);
1173 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001174 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001175 }
1176 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1177 if (has_dynamic_viewport_course_sample_order_nv == true) {
1178 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1179 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1180 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1181 i);
1182 }
1183 has_dynamic_viewport_course_sample_order_nv = true;
1184 }
1185 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1186 if (has_dynamic_line_stipple == true) {
1187 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1188 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1189 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1190 i);
1191 }
1192 has_dynamic_line_stipple = true;
1193 }
Petr Kraus299ba622017-11-24 03:09:03 +01001194 }
1195 }
1196
Peter Chen85366392019-05-14 15:20:11 -04001197 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1198 if ((feedback_struct != nullptr) &&
1199 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001200 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1201 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1202 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1203 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1204 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001205 }
1206
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001208
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001209 // Collect active stages and other information
1210 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001211 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001212 bool has_eval = false;
1213 bool has_control = false;
1214 if (pCreateInfos[i].pStages != nullptr) {
1215 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1216 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1217
1218 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1219 has_control = true;
1220 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1221 has_eval = true;
1222 }
1223
1224 skip |= validate_string(
1225 "vkCreateGraphicsPipelines",
1226 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1227 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1228 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001229 }
1230
1231 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1232 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1233 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1234 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1235 pCreateInfos[i].pTessellationState,
1236 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1237 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1238
1239 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1240 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1241
1242 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1243 "VkPipelineTessellationDomainOriginStateCreateInfo",
1244 pCreateInfos[i].pTessellationState->pNext,
1245 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1246 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001247 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1248 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001249
1250 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1251 pCreateInfos[i].pTessellationState->flags,
1252 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1253 }
1254
1255 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1256 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1257 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1258 pCreateInfos[i].pInputAssemblyState,
1259 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1260 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1261
1262 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1263 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001264 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001265
1266 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1267 pCreateInfos[i].pInputAssemblyState->flags,
1268 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1269
1270 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1271 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1272 pCreateInfos[i].pInputAssemblyState->topology,
1273 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1274
1275 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1276 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1277 }
1278
1279 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001280 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001281
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001282 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001283 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1284 "vkCreateGraphicsPipelines: pararameter "
1285 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1286 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001287 }
1288
1289 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1290 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1291 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1292 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1293 pCreateInfos[i].pVertexInputState->pNext, 1,
1294 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001295 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1296 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001297 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1298 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001299 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001300 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1301 skip |=
1302 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1303 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1304 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1305 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1306 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1307
1308 skip |= validate_array(
1309 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1310 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1311 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1312 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1313
1314 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1315 for (uint32_t vertexBindingDescriptionIndex = 0;
1316 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1317 ++vertexBindingDescriptionIndex) {
1318 skip |= validate_ranged_enum(
1319 "vkCreateGraphicsPipelines",
1320 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1321 AllVkVertexInputRateEnums,
1322 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1323 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1324 }
1325 }
1326
1327 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1328 for (uint32_t vertexAttributeDescriptionIndex = 0;
1329 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1330 ++vertexAttributeDescriptionIndex) {
1331 skip |= validate_ranged_enum(
1332 "vkCreateGraphicsPipelines",
1333 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1334 AllVkFormatEnums,
1335 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1336 "VUID-VkVertexInputAttributeDescription-format-parameter");
1337 }
1338 }
1339
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001340 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001341 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1342 "vkCreateGraphicsPipelines: pararameter "
1343 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1344 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1345 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001346 }
1347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001348 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001349 skip |=
1350 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1351 "vkCreateGraphicsPipelines: pararameter "
1352 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1353 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1354 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001355 }
1356
1357 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001358 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1359 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001360 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1361 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001362 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1363 "vkCreateGraphicsPipelines: parameter "
1364 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1365 "(%" PRIu32 ") is not distinct.",
1366 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001367 }
1368 vertex_bindings.insert(vertex_bind_desc.binding);
1369
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001370 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001371 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1372 "vkCreateGraphicsPipelines: parameter "
1373 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1374 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1375 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001376 }
1377
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001378 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001379 skip |=
1380 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1381 "vkCreateGraphicsPipelines: parameter "
1382 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1383 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1384 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001385 }
1386 }
1387
Peter Kohautc7d9d392018-07-15 00:34:07 +02001388 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001389 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1390 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001391 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1392 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001393 skip |= LogError(
1394 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001395 "vkCreateGraphicsPipelines: parameter "
1396 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1397 i, d, vertex_attrib_desc.location);
1398 }
1399 attribute_locations.insert(vertex_attrib_desc.location);
1400
1401 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1402 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(
1404 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001405 "vkCreateGraphicsPipelines: parameter "
1406 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1407 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1408 i, d, vertex_attrib_desc.binding, i);
1409 }
1410
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001411 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001412 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1413 "vkCreateGraphicsPipelines: parameter "
1414 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1415 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1416 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001417 }
1418
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001419 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001420 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1421 "vkCreateGraphicsPipelines: parameter "
1422 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1423 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1424 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001425 }
1426
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001427 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001428 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1429 "vkCreateGraphicsPipelines: parameter "
1430 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1431 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1432 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001433 }
1434 }
1435 }
1436
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001437 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1438 if (has_control && has_eval) {
1439 if (pCreateInfos[i].pTessellationState == nullptr) {
1440 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1441 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1442 "shader stage and a tessellation evaluation shader stage, "
1443 "pCreateInfos[%d].pTessellationState must not be NULL.",
1444 i, i);
1445 } else {
1446 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1447 skip |= validate_struct_pnext(
1448 "vkCreateGraphicsPipelines",
1449 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1450 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1451 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1452 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001453
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001454 skip |= validate_reserved_flags(
1455 "vkCreateGraphicsPipelines",
1456 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1457 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001458
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001459 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1460 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1461 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1462 "vkCreateGraphicsPipelines: invalid parameter "
1463 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1464 "should be >0 and <=%u.",
1465 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1466 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001467 }
1468 }
1469 }
1470
1471 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1472 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1473 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1474 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001475 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1476 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1477 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1478 "].pViewportState (=NULL) is not a valid pointer.",
1479 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001480 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001481 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1482
1483 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001484 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1485 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1486 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1487 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001488 }
1489
Petr Krausa6103552017-11-16 21:21:58 +01001490 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1491 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001492 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1493 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001494 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1495 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001496 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001497 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001498 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001499 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001500 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001501 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1502 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001503 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001504 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1505 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001506
1507 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001508 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001509 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001510 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001511
Dave Houlton142c4cb2018-10-17 15:04:41 -06001512 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1513 pCreateInfos[i].pViewportState->pNext);
1514 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1515 pCreateInfos[i].pViewportState->pNext);
1516 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1517 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001518 const auto vp_swizzle_struct =
1519 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001520 const auto vp_w_scaling_struct =
1521 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001522
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001523 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001524 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001525 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1526 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1527 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1528 ") is not 1.",
1529 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001530 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001531
Petr Krausa6103552017-11-16 21:21:58 +01001532 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001533 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1534 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1535 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1536 ") is not 1.",
1537 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001538 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001539
Dave Houlton142c4cb2018-10-17 15:04:41 -06001540 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1541 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001542 skip |= LogError(
1543 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1544 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1545 "disabled, but pCreateInfos[%" PRIu32
1546 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1547 ") is not 1.",
1548 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001549 }
1550
Jeff Bolz9af91c52018-09-01 21:53:57 -05001551 if (shading_rate_image_struct &&
1552 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001553 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1554 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1555 "disabled, but pCreateInfos[%" PRIu32
1556 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1557 ") is neither 0 nor 1.",
1558 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001559 }
1560
Petr Krausa6103552017-11-16 21:21:58 +01001561 } else { // multiViewport enabled
1562 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001563 skip |= LogError(
1564 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001565 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001566 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001567 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1568 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1569 "].pViewportState->viewportCount (=%" PRIu32
1570 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1571 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001572 }
Petr Krausa6103552017-11-16 21:21:58 +01001573
1574 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |= LogError(
1576 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001577 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001578 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001579 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1580 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1581 "].pViewportState->scissorCount (=%" PRIu32
1582 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1583 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001584 }
1585 }
1586
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001587 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001588 skip |=
1589 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1590 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1591 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1592 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001593 }
1594
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001595 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001596 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1597 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1598 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1599 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1600 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001601 }
1602
Petr Krausa6103552017-11-16 21:21:58 +01001603 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001604 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1605 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1606 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1607 "].pViewportState->viewportCount (=%" PRIu32 ").",
1608 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001609 }
1610
Dave Houlton142c4cb2018-10-17 15:04:41 -06001611 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001612 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001613 skip |=
1614 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1615 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1616 ") must be zero or identical to pCreateInfos[%" PRIu32
1617 "].pViewportState->viewportCount (=%" PRIu32 ").",
1618 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001619 }
1620
Dave Houlton142c4cb2018-10-17 15:04:41 -06001621 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001622 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001623 skip |= LogError(
1624 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001625 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1626 "] "
1627 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1628 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1629 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001630 }
1631
Petr Krausa6103552017-11-16 21:21:58 +01001632 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001633 skip |= LogError(
1634 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001635 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1636 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001637 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1638 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001639 }
1640
1641 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001642 skip |= LogError(
1643 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001644 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1645 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001646 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1647 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001648 }
1649
Jeff Bolz3e71f782018-08-29 23:15:45 -05001650 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001651 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1652 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1653 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001654 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1655 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1656 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1657 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1658 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001659 }
1660
Jeff Bolz9af91c52018-09-01 21:53:57 -05001661 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001662 shading_rate_image_struct->viewportCount > 0 &&
1663 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001664 skip |= LogError(
1665 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001666 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001667 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1668 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001669 i, i);
1670 }
1671
Chris Mayer328d8212018-12-11 14:16:18 +01001672 if (vp_swizzle_struct) {
1673 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001674 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1675 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1676 " does "
1677 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1678 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001679 }
1680 }
1681
Petr Krausb3fcdb42018-01-09 22:09:09 +01001682 // validate the VkViewports
1683 if (!has_dynamic_viewport && viewport_state.pViewports) {
1684 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1685 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001686 const char *fn_name = "vkCreateGraphicsPipelines";
1687 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1688 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1689 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001690 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001691 }
1692 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001693
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001694 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001695 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1696 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1697 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1698 "VK_NV_clip_space_w_scaling extension is not enabled.",
1699 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001700 }
1701
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001702 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001703 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1704 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1705 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1706 "VK_EXT_discard_rectangles extension is not enabled.",
1707 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001708 }
1709
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001710 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001711 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1712 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1713 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1714 "VK_EXT_sample_locations extension is not enabled.",
1715 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001716 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001717
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001718 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001719 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1720 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1721 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1722 "VK_NV_scissor_exclusive extension is not enabled.",
1723 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001724 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001725
1726 if (coarse_sample_order_struct &&
1727 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1728 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001729 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1730 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1731 "] "
1732 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1733 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1734 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001735 }
1736
1737 if (coarse_sample_order_struct) {
1738 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001739 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001740 }
1741 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001742
1743 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1744 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001745 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1746 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1747 "] "
1748 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1749 ") "
1750 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1751 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001752 }
1753 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001754 skip |= LogError(
1755 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001756 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1757 "] "
1758 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1759 i);
1760 }
1761 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001762 }
1763
1764 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001765 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1766 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1767 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1768 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001769 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001770 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1771 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1772 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001773 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001774 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001775 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001776 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001777 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001778 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001779 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001780 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1781 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001782
1783 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001784 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001785 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001786 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001787
1788 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001789 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001790 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1791 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1792
1793 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001794 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001795 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1796 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001797 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001798 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001799
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001800 skip |= validate_flags(
1801 "vkCreateGraphicsPipelines",
1802 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1803 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001804 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001805
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001806 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001807 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001808 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1809 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1810
1811 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001812 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001813 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1814 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1815
1816 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001817 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1818 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1819 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1820 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001821 }
John Zulauf7acac592017-11-06 11:15:53 -07001822 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001823 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001824 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1825 "vkCreateGraphicsPipelines(): parameter "
1826 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1827 i);
John Zulauf7acac592017-11-06 11:15:53 -07001828 }
1829 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1830 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1831 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001832 skip |= LogError(
1833 device,
1834
Dave Houlton413a6782018-05-22 13:01:54 -06001835 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001836 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001837 }
1838 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001839
1840 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1841 pCreateInfos[i].pRasterizationState->pNext);
1842
1843 if (line_state) {
1844 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1845 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1846 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1847 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001848 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1849 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1850 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1851 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001852 }
1853 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1854 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001855 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1856 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1857 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1858 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001859 }
1860 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1861 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001862 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1863 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1864 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1865 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001866 }
1867 }
1868 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1869 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1870 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1872 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1873 "range [1,256].",
1874 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001875 }
1876 }
1877 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001878 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001879 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1880 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001881 skip |=
1882 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1883 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1884 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1885 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001886 }
1887 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1888 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001889 skip |=
1890 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1891 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1892 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1893 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001894 }
1895 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1896 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001897 skip |=
1898 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1899 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1900 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1901 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001902 }
1903 if (line_state->stippledLineEnable) {
1904 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1905 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001906 skip |=
1907 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1908 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1909 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1910 "stippledRectangularLines feature.",
1911 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001912 }
1913 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1914 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001915 skip |=
1916 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1917 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1918 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1919 "stippledBresenhamLines feature.",
1920 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001921 }
1922 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1923 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001924 skip |=
1925 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1926 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1927 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1928 "stippledSmoothLines feature.",
1929 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001930 }
1931 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1932 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001933 skip |=
1934 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1935 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1936 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1937 "stippledRectangularLines and strictLines features.",
1938 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001939 }
1940 }
1941 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001942 }
1943
Petr Krause91f7a12017-12-14 20:57:36 +01001944 bool uses_color_attachment = false;
1945 bool uses_depthstencil_attachment = false;
1946 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001947 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001948 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1949 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001950 const auto &subpasses_uses = subpasses_uses_it->second;
1951 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1952 uses_color_attachment = true;
1953 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1954 uses_depthstencil_attachment = true;
1955 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001956 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001957 }
1958
1959 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001960 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001962 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001963 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001964 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001965
1966 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001967 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001969 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001970
1971 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001972 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001973 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1974 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1975
1976 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001977 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001978 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1979 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1980
1981 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001982 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001983 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1984 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001985 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001986
1987 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1990 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1991
1992 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1995 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1996
1997 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001998 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001999 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2000 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002001 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002
2003 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002004 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002005 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2006 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002007 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002008
2009 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002010 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002011 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2012 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002013 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002014
2015 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002016 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002017 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2018 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002019 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002020
2021 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002022 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002023 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2024 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002025 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002026
2027 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002028 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002029 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2030 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002031 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002032
2033 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002034 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002035 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2036 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002037 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002038
2039 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002040 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002041 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2042 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002043 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002044
2045 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002046 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2047 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2048 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2049 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002050 }
2051 }
2052
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002053 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2054 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2055
Petr Krause91f7a12017-12-14 20:57:36 +01002056 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002057 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2058 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2059 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2060 pCreateInfos[i].pColorBlendState,
2061 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2062 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2063
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002064 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002065 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002066 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2067 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2068 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002069 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002070 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2071 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072
2073 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002074 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002075 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002076 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002077
2078 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002079 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002080 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2081 pCreateInfos[i].pColorBlendState->logicOpEnable);
2082
2083 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002084 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002085 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2086 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002087 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002088 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089
2090 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2091 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2092 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002093 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002094 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2095 ParameterName::IndexVector{i, attachmentIndex}),
2096 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2097
2098 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002099 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002100 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2101 ParameterName::IndexVector{i, attachmentIndex}),
2102 "VkBlendFactor", AllVkBlendFactorEnums,
2103 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002104 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002105
2106 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002107 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002108 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2109 ParameterName::IndexVector{i, attachmentIndex}),
2110 "VkBlendFactor", AllVkBlendFactorEnums,
2111 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002112 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002113
2114 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002115 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002116 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2117 ParameterName::IndexVector{i, attachmentIndex}),
2118 "VkBlendOp", AllVkBlendOpEnums,
2119 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002120 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002121
2122 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002123 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002124 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2125 ParameterName::IndexVector{i, attachmentIndex}),
2126 "VkBlendFactor", AllVkBlendFactorEnums,
2127 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002128 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002129
2130 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002131 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2133 ParameterName::IndexVector{i, attachmentIndex}),
2134 "VkBlendFactor", AllVkBlendFactorEnums,
2135 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002136 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002137
2138 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002139 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002140 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2141 ParameterName::IndexVector{i, attachmentIndex}),
2142 "VkBlendOp", AllVkBlendOpEnums,
2143 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002144 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002145
2146 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002147 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002148 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2149 ParameterName::IndexVector{i, attachmentIndex}),
2150 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2151 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002152 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002153 }
2154 }
2155
2156 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002157 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2158 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2159 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2160 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002161 }
2162
2163 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2164 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2165 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002166 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002167 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002168 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2169 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 }
2171 }
2172 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173
Petr Kraus9752aae2017-11-24 03:05:50 +01002174 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2175 if (pCreateInfos[i].basePipelineIndex != -1) {
2176 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002177 skip |=
2178 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2179 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2180 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2181 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002182 }
2183 }
2184
Petr Kraus9752aae2017-11-24 03:05:50 +01002185 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2186 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002187 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2188 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2189 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2190 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002191 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002192 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002193 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002194 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2195 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2196 "index into the pCreateInfos array, of size %d.",
2197 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002198 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002199 }
2200 }
2201
Petr Kraus9752aae2017-11-24 03:05:50 +01002202 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002203 if (!device_extensions.vk_nv_fill_rectangle) {
2204 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2205 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002206 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2207 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2208 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2209 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002210 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2211 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002212 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2213 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2214 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2215 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002216 }
2217 } else {
2218 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2219 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2220 (physical_device_features.fillModeNonSolid == false)) {
2221 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002222 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2223 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2224 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2225 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002226 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002227 }
Petr Kraus299ba622017-11-24 03:09:03 +01002228
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002229 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002230 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002231 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2232 "The line width state is static (pCreateInfos[%" PRIu32
2233 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2234 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2235 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2236 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002237 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002238 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002239 }
2240 }
2241
2242 return skip;
2243}
2244
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002245bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2246 uint32_t createInfoCount,
2247 const VkComputePipelineCreateInfo *pCreateInfos,
2248 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002249 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002250 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002252 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002254 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002255 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2256 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002257 skip |=
2258 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2259 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2260 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2261 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002262 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002263
2264 // Make sure compute stage is selected
2265 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002266 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2267 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2268 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002269 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002271 return skip;
2272}
2273
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002274bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002275 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002276 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002277
2278 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002279 const auto &features = physical_device_features;
2280 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002281
John Zulauf71968502017-10-26 13:51:15 -06002282 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2283 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002284 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2285 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2286 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2287 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002288 }
2289
2290 // Anistropy cannot be enabled in sampler unless enabled as a feature
2291 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002292 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2293 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2294 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002295 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002296 }
John Zulauf71968502017-10-26 13:51:15 -06002297
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002298 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2299 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002300 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2301 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2302 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2303 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002304 }
2305 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002306 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2307 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2308 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2309 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002310 }
2311 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002312 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2313 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2314 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2315 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002316 }
2317 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2318 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2319 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2320 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002321 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2322 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2323 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2324 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2325 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2326 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002327 }
2328 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2330 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2331 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002332 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002333 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002334 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2335 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2336 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002337 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002338 }
2339
2340 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2341 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002342 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2343 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002344 }
2345
2346 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2347 // valid VkBorderColor value
2348 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2349 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2350 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002351 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2352 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002353 }
2354
2355 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2356 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002357 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002358 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2359 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2360 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002361 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002362 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2363 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2364 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002365 }
John Zulauf275805c2017-10-26 15:34:49 -06002366
2367 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002368 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002369 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2370 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2372 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2373 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002374 }
2375 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002376
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002377 // Check for valid Lod range
2378 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002379 skip |=
2380 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2381 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002382 }
2383
2384 // Check mipLodBias to device limit
2385 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002386 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2387 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2388 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002389 }
2390
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002391 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2392 if (sampler_conversion != nullptr) {
2393 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2394 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2395 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2396 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002397 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002398 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002399 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2400 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2401 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2402 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2403 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2404 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2405 }
2406 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002407 }
2408
2409 return skip;
2410}
2411
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002412bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2413 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2414 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002415 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002416 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417
2418 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2419 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2420 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2421 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002422 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2423 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2424 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2425 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2426 ++descriptor_index) {
2427 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002428 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002429 "vkCreateDescriptorSetLayout: required parameter "
2430 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2431 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002432 }
2433 }
2434 }
2435
2436 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2437 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2438 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002439 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2440 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2441 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2442 "values.",
2443 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002445
2446 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2447 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2448 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2449 skip |=
2450 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2451 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2452 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2453 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2454 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2455 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002456 }
2457 }
2458 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459 return skip;
2460}
2461
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002462bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2463 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002464 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2466 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2467 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002468 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2469 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002470}
2471
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002472bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2473 const VkWriteDescriptorSet *pDescriptorWrites,
2474 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002475 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002476
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 if (pDescriptorWrites != NULL) {
2478 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2479 // descriptorCount must be greater than 0
2480 if (pDescriptorWrites[i].descriptorCount == 0) {
2481 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002482 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2483 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002484 }
2485
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002486 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2487 if (validateDstSet) {
2488 // dstSet must be a valid VkDescriptorSet handle
2489 skip |= validate_required_handle(vkCallingFunction,
2490 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2491 pDescriptorWrites[i].dstSet);
2492 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002493
2494 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2495 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2496 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2497 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2498 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2499 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2500 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2501 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2502 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002503 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2504 "%s(): if pDescriptorWrites[%d].descriptorType is "
2505 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2506 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2507 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2508 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2510 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2511 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2512 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2513 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2514 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002515 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002516 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2517 ParameterName::IndexVector{i, descriptor_index}),
2518 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002519 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2521 ParameterName::IndexVector{i, descriptor_index}),
2522 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002523 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002524 }
2525 }
2526 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2527 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2528 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2529 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2530 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2531 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2532 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2533 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002534 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2535 "%s(): if pDescriptorWrites[%d].descriptorType is "
2536 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2537 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2538 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2539 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540 } else {
2541 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002542 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002543 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2544 ParameterName::IndexVector{i, descriptorIndex}),
2545 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2546 }
2547 }
2548 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2549 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2550 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2551 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2552 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002553 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2554 "%s(): if pDescriptorWrites[%d].descriptorType is "
2555 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2556 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2557 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 } else {
2559 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2560 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002561 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002562 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2563 ParameterName::IndexVector{i, descriptor_index}),
2564 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2565 }
2566 }
2567 }
2568
2569 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2570 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002571 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2573 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2574 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002575 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002576 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2577 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2578 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2579 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002580 }
2581 }
2582 }
2583 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2584 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002585 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002586 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2587 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2588 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002589 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002590 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2591 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2592 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2593 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 }
2595 }
2596 }
2597 }
2598 }
2599 }
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002600
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601 return skip;
2602}
2603
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002604bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2605 const VkWriteDescriptorSet *pDescriptorWrites,
2606 uint32_t descriptorCopyCount,
2607 const VkCopyDescriptorSet *pDescriptorCopies) const {
2608 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2609}
2610
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002611bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002612 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002613 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2615}
2616
2617bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002618 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002619 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002620 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2621}
2622
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002623bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2624 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002625 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627
2628 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2629 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2630 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002631 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2632 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633 return skip;
2634}
2635
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002636bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002637 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002639
2640 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2641 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2643
Petr Krause7bb9e82019-08-11 21:34:43 +02002644 // Implicit VUs
2645 // validate only sType here; pointer has to be validated in core_validation
2646 const bool kNotRequired = false;
2647 const char *kNoVUID = nullptr;
2648 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2649 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2650 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002651
Petr Krause7bb9e82019-08-11 21:34:43 +02002652 if (pInfo) {
2653 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2654 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2655 skip |= validate_struct_pnext(
2656 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2657 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002658 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2659 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660
Petr Krause7bb9e82019-08-11 21:34:43 +02002661 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662
Petr Krause7bb9e82019-08-11 21:34:43 +02002663 // Explicit VUs
2664 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002665 skip |= LogError(
2666 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002667 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2668 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002669 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002670
2671 if (physical_device_features.inheritedQueries) {
2672 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002673 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002674 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002675 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002676 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002677 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002678 }
2679
2680 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002681 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002682 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002683 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002684 } else { // !pipelineStatisticsQuery
2685 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2686 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 }
Petr Kraus139757b2019-08-15 17:19:33 +02002688
2689 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2690 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002691 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002692 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2693 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002694 skip |= LogError(
2695 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002696 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2697 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2698 }
2699 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002700 }
2701
2702 return skip;
2703}
2704
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002705bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002706 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002709 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002710 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002711 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2712 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2713 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002714 }
2715 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2717 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2718 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002719 }
2720 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002721 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002722 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002723 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2724 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2725 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2726 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727 }
2728 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002729
2730 if (pViewports) {
2731 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2732 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002733 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002734 skip |= manual_PreCallValidateViewport(
2735 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002736 }
2737 }
2738
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739 return skip;
2740}
2741
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002742bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002743 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002746 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002748 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2749 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2750 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002751 }
2752 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002753 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2754 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2755 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002756 }
2757 } else { // multiViewport enabled
2758 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002759 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002760 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2761 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2762 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2763 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764 }
2765 }
2766
Petr Kraus6260f0a2018-02-27 21:15:55 +01002767 if (pScissors) {
2768 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2769 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002770
Petr Kraus6260f0a2018-02-27 21:15:55 +01002771 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002772 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2773 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2774 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002775 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002776
Petr Kraus6260f0a2018-02-27 21:15:55 +01002777 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2779 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2780 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002781 }
2782
2783 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2784 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002785 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2786 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2787 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2788 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002789 }
2790
2791 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2792 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002793 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2794 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2795 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2796 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002797 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798 }
2799 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002800
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002801 return skip;
2802}
2803
Jeff Bolz5c801d12019-10-09 10:38:45 -05002804bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002805 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002806
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002807 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002808 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2809 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002810 }
2811
2812 return skip;
2813}
2814
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002815bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002816 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002818 if (vertexCount == 0) {
2819 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2820 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002821 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 }
2823
2824 if (instanceCount == 0) {
2825 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2826 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002828 }
2829 return skip;
2830}
2831
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002832bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002833 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002834 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002836 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002837 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2838 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 }
2840 return skip;
2841}
2842
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002843bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002844 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002846 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002847 skip |=
2848 LogError(device, kVUID_PVError_DeviceFeature,
2849 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002850 }
2851 return skip;
2852}
2853
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002854bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2855 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002856 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002857 bool skip = false;
2858 for (uint32_t rect = 0; rect < rectCount; rect++) {
2859 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2861 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002862 }
2863 }
2864 return skip;
2865}
2866
Andrew Fobel3abeb992020-01-20 16:33:22 -05002867bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2868 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2869 VkImageFormatProperties2 *pImageFormatProperties,
2870 const char *apiName) const {
2871 bool skip = false;
2872
2873 if (pImageFormatInfo != nullptr) {
2874 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2875 if (image_stencil_struct != nullptr) {
2876 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2877 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2878 // No flags other than the legal attachment bits may be set
2879 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2880 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002881 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2882 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2883 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2884 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2885 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002886 }
2887 }
2888 }
2889 }
2890
2891 return skip;
2892}
2893
2894bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2895 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2896 VkImageFormatProperties2 *pImageFormatProperties) const {
2897 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2898 "vkGetPhysicalDeviceImageFormatProperties2");
2899}
2900
2901bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2902 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2903 VkImageFormatProperties2 *pImageFormatProperties) const {
2904 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2905 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2906}
2907
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002908bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2909 VkImageLayout srcImageLayout, VkImage dstImage,
2910 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002911 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002912 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002913
Dave Houltonf5217612018-02-02 16:18:52 -07002914 VkImageAspectFlags legal_aspect_flags =
2915 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 -07002916 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002917 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2918 }
2919
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002921 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002922 skip |= LogError(
2923 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002924 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925 }
Dave Houltonf5217612018-02-02 16:18:52 -07002926 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002927 skip |= LogError(
2928 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002929 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002930 }
2931 }
2932 return skip;
2933}
2934
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002935bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2936 VkImageLayout srcImageLayout, VkImage dstImage,
2937 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002938 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002939 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940
Dave Houltonf5217612018-02-02 16:18:52 -07002941 VkImageAspectFlags legal_aspect_flags =
2942 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 -07002943 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002944 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2945 }
2946
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002948 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002949 skip |= LogError(
2950 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2952 }
Dave Houltonf5217612018-02-02 16:18:52 -07002953 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002954 skip |= LogError(
2955 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2957 }
2958 }
2959 return skip;
2960}
2961
sfricke-samsung3999ef62020-02-09 17:05:59 -08002962bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
2963 uint32_t regionCount, const VkBufferCopy *pRegions) const {
2964 bool skip = false;
2965
2966 if (pRegions != nullptr) {
2967 for (uint32_t i = 0; i < regionCount; i++) {
2968 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002969 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
2970 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08002971 }
2972 }
2973 }
2974 return skip;
2975}
2976
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002977bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2978 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002979 uint32_t regionCount,
2980 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002982
Dave Houltonf5217612018-02-02 16:18:52 -07002983 VkImageAspectFlags legal_aspect_flags =
2984 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 -07002985 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002986 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2987 }
2988
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002990 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002991 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
2992 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2993 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 }
2995 }
2996 return skip;
2997}
2998
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002999bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3000 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003001 uint32_t regionCount,
3002 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003003 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004
Dave Houltonf5217612018-02-02 16:18:52 -07003005 VkImageAspectFlags legal_aspect_flags =
3006 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 -07003007 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003008 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3009 }
3010
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003012 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003013 LogError(device, kVUID_PVError_UnrecognizedValue,
3014 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3015 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003016 }
3017 }
3018 return skip;
3019}
3020
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003021bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003022 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3023 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003024 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025
3026 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3028 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3029 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003030 }
3031
3032 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003033 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3034 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3035 "), must be greater than zero and less than or equal to 65536.",
3036 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003038 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3039 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3040 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 }
3042 return skip;
3043}
3044
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003045bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003046 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048
3049 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003050 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3051 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3052 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 }
3054
3055 if (size != VK_WHOLE_SIZE) {
3056 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003057 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3059 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003061 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3062 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063 }
3064 }
3065 return skip;
3066}
3067
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003068bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003069 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003070 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072
3073 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003074 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3075 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3076 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3077 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003078 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3079 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3080 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003081 }
3082
3083 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3084 // queueFamilyIndexCount uint32_t values
3085 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003086 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3087 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3088 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3089 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090 }
3091 }
3092
Dave Houlton413a6782018-05-22 13:01:54 -06003093 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003095 }
3096
3097 return skip;
3098}
3099
Jeff Bolz5c801d12019-10-09 10:38:45 -05003100bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003101 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003102
3103 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003104 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3105 if (present_regions) {
3106 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003107 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003108 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3109 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3111 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3112 "extension swapchainCount is %i. These values must be equal.",
3113 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003114 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003115 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003116 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3117 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003118 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3119 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3120 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003121 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003122 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003124 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003125 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003126 }
3127 }
3128
3129 return skip;
3130}
3131
3132#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003133bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3134 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3135 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003136 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 bool skip = false;
3138
3139 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003140 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3141 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 }
3143
3144 return skip;
3145}
3146#endif // VK_USE_PLATFORM_WIN32_KHR
3147
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003148bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003149 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003150 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003151 bool skip = false;
3152
3153 if (pCreateInfo) {
3154 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003155 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3156 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003157 }
3158
3159 if (pCreateInfo->pPoolSizes) {
3160 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3161 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003162 skip |= LogError(
3163 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003164 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003165 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003166 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3167 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003168 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3169 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3170 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3171 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3172 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003173 }
Petr Krausc8655be2017-09-27 18:56:51 +02003174 }
3175 }
3176 }
3177
3178 return skip;
3179}
3180
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003181bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003182 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003183 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003184
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003185 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003186 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003187 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3188 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3189 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003190 }
3191
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003192 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003193 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003194 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3195 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3196 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003197 }
3198
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003199 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003200 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003201 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3202 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3203 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003204 }
3205
3206 return skip;
3207}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003208
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003209bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003210 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003211 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003212
3213 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003214 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3215 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003216 }
3217 return skip;
3218}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003219
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003220bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3221 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003222 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003223 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003224
3225 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003226 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003227 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003228 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3229 "vkCmdDispatch(): baseGroupX (%" PRIu32
3230 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3231 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003232 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003233 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3234 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3235 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3236 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003237 }
3238
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003239 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003240 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003241 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3242 "vkCmdDispatch(): baseGroupY (%" PRIu32
3243 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3244 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003245 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003246 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3247 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3248 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3249 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003250 }
3251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003253 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003254 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3255 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3256 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3257 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003258 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3260 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3261 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3262 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003263 }
3264
3265 return skip;
3266}
3267
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003268bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3269 VkPipelineBindPoint pipelineBindPoint,
3270 VkPipelineLayout layout, uint32_t set,
3271 uint32_t descriptorWriteCount,
3272 const VkWriteDescriptorSet *pDescriptorWrites) const {
3273 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3274}
3275
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003276bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3277 uint32_t firstExclusiveScissor,
3278 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003279 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003280 bool skip = false;
3281
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003282 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003283 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003284 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3286 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3287 ") is not 0.",
3288 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003289 }
3290 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003291 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003292 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3293 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3294 ") is not 1.",
3295 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003296 }
3297 } else { // multiViewport enabled
3298 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003299 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003300 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3301 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3302 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3303 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003304 }
3305 }
3306
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003307 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003308 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3309 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3310 ") must be less than maxViewports (=%" PRIu32 ").",
3311 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003312 }
3313
3314 if (pExclusiveScissors) {
3315 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3316 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3317
3318 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003319 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3320 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3321 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003322 }
3323
3324 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003325 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3326 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3327 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003328 }
3329
3330 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3331 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003332 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3333 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3334 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3335 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003336 }
3337
3338 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3339 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003340 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3341 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3342 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3343 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003344 }
3345 }
3346 }
3347
3348 return skip;
3349}
3350
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003351bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3352 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003353 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003354 bool skip = false;
3355 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003356 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3357 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3358 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003359 } else {
3360 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3361 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003362 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3363 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3364 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3365 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003366 }
3367 }
3368
3369 return skip;
3370}
3371
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003372bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3373 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003374 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003375 bool skip = false;
3376
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003377 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003378 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003379 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003380 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3381 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3382 ") is not 0.",
3383 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003384 }
3385 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003386 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003387 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3388 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3389 ") is not 1.",
3390 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003391 }
3392 }
3393
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003394 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003395 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3396 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3397 ") must be less than maxViewports (=%" PRIu32 ").",
3398 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003399 }
3400
3401 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003402 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003403 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3404 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3405 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3406 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003407 }
3408
3409 return skip;
3410}
3411
Jeff Bolz5c801d12019-10-09 10:38:45 -05003412bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3413 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3414 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003415 bool skip = false;
3416
Dave Houlton142c4cb2018-10-17 15:04:41 -06003417 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003418 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3419 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3420 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003421 }
3422
3423 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003424 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003425 }
3426
3427 return skip;
3428}
3429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003430bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003431 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003432 bool skip = false;
3433
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003434 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003435 skip |= LogError(
3436 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003437 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3438 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003439 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003440 }
3441
3442 return skip;
3443}
3444
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003445bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3446 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003447 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003448 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003449 static const int condition_multiples = 0b0011;
3450 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003451 skip |= LogError(
3452 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003453 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003454 }
Lockee1c22882019-06-10 16:02:54 -06003455 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003456 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3457 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3458 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3459 stride);
Lockee1c22882019-06-10 16:02:54 -06003460 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003461 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003462 skip |= LogError(
3463 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3464 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003465 }
3466
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003467 return skip;
3468}
3469
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003470bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3471 VkDeviceSize offset, VkBuffer countBuffer,
3472 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003473 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003474 bool skip = false;
3475
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003476 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003477 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3478 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3479 "), is not a multiple of 4.",
3480 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003481 }
3482
3483 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3485 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3486 "), is not a multiple of 4.",
3487 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003488 }
3489
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003490 return skip;
3491}
3492
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003493bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003494 const VkAllocationCallbacks *pAllocator,
3495 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003496 bool skip = false;
3497
3498 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3499 if (pCreateInfo != nullptr) {
3500 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3501 // VkQueryPipelineStatisticFlagBits values
3502 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3503 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003504 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3505 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3506 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3507 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003508 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003509 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003510 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511}
3512
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003513bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3514 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003515 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003516 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3517 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003518}
3519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003520void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003521 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3522 VkResult result) {
3523 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003524 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003525}
3526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003527void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003528 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3529 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003530 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003531 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003532 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533}
3534
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003535void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3536 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003537 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003538 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003539 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003541
3542bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003543 const VkAllocationCallbacks *pAllocator,
3544 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003545 bool skip = false;
3546
3547 if (pAllocateInfo) {
3548 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3549 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3551 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003552 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003553
3554 VkMemoryAllocateFlags flags = 0;
3555 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3556 if (flags_info) {
3557 flags = flags_info->flags;
3558 }
3559
3560 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3561 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3562 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003563 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3564 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3565 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003566 }
3567
3568#ifdef VK_USE_PLATFORM_WIN32_KHR
3569 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3570#endif
3571 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3572 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3573#ifdef VK_USE_PLATFORM_ANDROID_KHR
3574 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3575#endif
3576
3577 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003578 skip |= LogError(
3579 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003580 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3581 }
3582 if (
3583#ifdef VK_USE_PLATFORM_WIN32_KHR
3584 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3585#endif
3586 (import_memory_fd && import_memory_fd->handleType) ||
3587#ifdef VK_USE_PLATFORM_ANDROID_KHR
3588 (import_memory_ahb && import_memory_ahb->buffer) ||
3589#endif
3590 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003591 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3592 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003593 }
3594 }
3595
3596 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003597 VkBool32 capture_replay = false;
3598 VkBool32 buffer_device_address = false;
3599 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3600 if (vulkan_12_features) {
3601 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3602 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3603 } else {
3604 const auto *bda_features =
3605 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3606 if (bda_features) {
3607 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3608 buffer_device_address = bda_features->bufferDeviceAddress;
3609 }
3610 }
3611 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003612 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3613 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3614 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003615 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003616 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003617 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3618 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003619 }
3620 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003621 }
3622 return skip;
3623}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003624
Jason Macnak192fa0e2019-07-26 15:07:16 -07003625bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003627 bool skip = false;
3628
3629 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3630 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3631 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003632 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003633 } else {
3634 uint32_t vertex_component_size = 0;
3635 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3636 vertex_component_size = 4;
3637 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3638 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3639 vertex_component_size = 2;
3640 }
3641 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003642 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003643 }
3644 }
3645
3646 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3647 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003648 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003649 } else {
3650 uint32_t index_element_size = 0;
3651 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3652 index_element_size = 4;
3653 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3654 index_element_size = 2;
3655 }
3656 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003657 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003658 }
3659 }
3660 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3661 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003663 }
3664 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003666 }
3667 }
3668
3669 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003671 }
3672
3673 return skip;
3674}
3675
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003676bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3677 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003678 bool skip = false;
3679
3680 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003681 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003682 }
3683 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003684 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003685 }
3686
3687 return skip;
3688}
3689
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003690bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3691 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003692 bool skip = false;
3693 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003694 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003695 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003696 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003697 }
3698 return skip;
3699}
3700
3701bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003702 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003703 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003704 bool skip = false;
3705 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003706 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3707 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3708 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003709 }
3710 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003711 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3712 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3713 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003714 }
3715 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3716 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3718 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3719 "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 -07003720 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003721 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003722 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3723 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3724 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003725 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003726 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003727 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3728 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3729 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003730 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003731 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003732 uint64_t total_triangle_count = 0;
3733 for (uint32_t i = 0; i < info.geometryCount; i++) {
3734 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003735
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003736 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003737
Jason Macnak5c954952019-07-09 15:46:12 -07003738 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3739 continue;
3740 }
3741 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3742 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003743 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3745 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3746 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003747 }
3748 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003749 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3750 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3751 for (uint32_t i = 1; i < info.geometryCount; i++) {
3752 const VkGeometryNV &geometry = info.pGeometries[i];
3753 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003754 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003755 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3756 "info.pGeometries[0].geometryType.",
3757 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003758 }
3759 }
3760 }
Jason Macnak5c954952019-07-09 15:46:12 -07003761 return skip;
3762}
3763
Ricardo Garciaa4935972019-02-21 17:43:18 +01003764bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3765 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003766 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003767 bool skip = false;
3768
3769 if (pCreateInfo) {
3770 if ((pCreateInfo->compactedSize != 0) &&
3771 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003772 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3773 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3774 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3775 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003776 }
Jason Macnak5c954952019-07-09 15:46:12 -07003777
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003778 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003779 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003780 }
3781
3782 return skip;
3783}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003784
Jeff Bolz5c801d12019-10-09 10:38:45 -05003785bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3786 const VkAccelerationStructureInfoNV *pInfo,
3787 VkBuffer instanceData, VkDeviceSize instanceOffset,
3788 VkBool32 update, VkAccelerationStructureNV dst,
3789 VkAccelerationStructureNV src, VkBuffer scratch,
3790 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003791 bool skip = false;
3792
3793 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003794 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003795 }
3796
3797 return skip;
3798}
3799
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003800bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
3801 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3802 VkAccelerationStructureKHR *pAccelerationStructure) const {
3803 bool skip = false;
3804
3805 if (pCreateInfo) {
3806 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
3807 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3808 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3809 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
3810 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
3811 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3812 i);
3813 }
3814 }
3815
3816 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
3817 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
3818 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
3819 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
3820 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
3821 i);
3822 }
3823 }
3824 }
3825
3826 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
3827 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
3828 skip |= LogError(
3829 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
3830 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
3831 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
3832 }
3833
3834 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
3835 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
3836 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
3837 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
3838 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
3839 }
3840
3841 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
3842 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
3843 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
3844 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
3845 if (geometry_type != first_geometry_type) {
3846 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
3847 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
3848 "pGeometryInfos[0].geometryType.",
3849 i);
3850 }
3851 }
3852 }
3853 }
3854
3855 return skip;
3856}
3857
Jason Macnak5c954952019-07-09 15:46:12 -07003858bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3859 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003860 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003861 bool skip = false;
3862 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003863 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3864 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003865 }
3866 return skip;
3867}
3868
Peter Chen85366392019-05-14 15:20:11 -04003869bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3870 uint32_t createInfoCount,
3871 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3872 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003873 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003874 bool skip = false;
3875
3876 for (uint32_t i = 0; i < createInfoCount; i++) {
3877 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3878 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003879 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3880 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3881 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3882 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3883 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04003884 }
3885 }
3886
3887 return skip;
3888}
3889
Jeff Bolz443c2ca2020-03-19 12:11:51 -05003890bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
3891 uint32_t createInfoCount,
3892 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
3893 const VkAllocationCallbacks *pAllocator,
3894 VkPipeline *pPipelines) const {
3895 bool skip = false;
3896
3897 for (uint32_t i = 0; i < createInfoCount; i++) {
3898 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3899 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
3900 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3901 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
3902 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3903 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
3904 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
3905 }
3906 }
3907
3908 return skip;
3909}
3910
Mike Schuchardt21638df2019-03-16 10:52:02 -07003911#ifdef VK_USE_PLATFORM_WIN32_KHR
3912bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3913 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003914 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003915 bool skip = false;
3916 if (!device_extensions.vk_khr_swapchain)
3917 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3918 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3919 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3920 if (!device_extensions.vk_khr_surface)
3921 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3922 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3923 skip |=
3924 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3925 if (!device_extensions.vk_ext_full_screen_exclusive)
3926 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3927 skip |= validate_struct_type(
3928 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3929 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3930 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3931 if (pSurfaceInfo != NULL) {
3932 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3933 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3934 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3935
3936 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3937 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3938 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3939 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003940 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
3941 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07003942
3943 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3944 }
3945 return skip;
3946}
3947#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003948
3949bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3950 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003951 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003952 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3953 bool skip = false;
3954 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3955 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3956 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3957 }
3958 return skip;
3959}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003960
3961bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003962 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003963 bool skip = false;
3964
3965 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003966 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3967 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003968 }
3969
3970 return skip;
3971}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003972
3973bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003974 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003975 bool skip = false;
3976
3977 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003978 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
3979 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003980 }
3981
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003982 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003983 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003984 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
3985 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003986 }
3987
3988 return skip;
3989}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003990
sfricke-samsung4ada8d42020-02-09 17:43:11 -08003991bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
3992 uint32_t bindingCount, const VkBuffer *pBuffers,
3993 const VkDeviceSize *pOffsets) const {
3994 bool skip = false;
3995 if (firstBinding > device_limits.maxVertexInputBindings) {
3996 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
3997 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
3998 device_limits.maxVertexInputBindings);
3999 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4000 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4001 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4002 "maxVertexInputBindings (%u)",
4003 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4004 }
4005
4006 return skip;
4007}
4008
Mark Lobodzinski84988402019-09-11 15:27:30 -06004009bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004010 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004011 bool skip = false;
4012 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004013 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4014 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004015 }
4016 return skip;
4017}
4018
4019bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004020 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004021 bool skip = false;
4022 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004023 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4024 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004025 }
4026 return skip;
4027}
Petr Kraus3d720392019-11-13 02:52:39 +01004028
4029bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4030 VkSemaphore semaphore, VkFence fence,
4031 uint32_t *pImageIndex) const {
4032 bool skip = false;
4033
4034 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004035 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4036 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004037 }
4038
4039 return skip;
4040}
4041
4042bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4043 uint32_t *pImageIndex) const {
4044 bool skip = false;
4045
4046 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4048 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004049 }
4050
4051 return skip;
4052}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004053
4054bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4055 uint32_t firstInstance, VkBuffer counterBuffer,
4056 VkDeviceSize counterBufferOffset,
4057 uint32_t counterOffset, uint32_t vertexStride) const {
4058 bool skip = false;
4059
4060 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004061 skip |= LogError(
4062 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004063 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4064 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4065 }
4066
4067 return skip;
4068}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004069
4070bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4071 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4072 const VkAllocationCallbacks *pAllocator,
4073 VkSamplerYcbcrConversion *pYcbcrConversion,
4074 const char *apiName) const {
4075 bool skip = false;
4076
4077 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004078 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004079 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004080 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4081 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004082 }
4083 return skip;
4084}
4085
4086bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4087 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4088 const VkAllocationCallbacks *pAllocator,
4089 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4090 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4091 "vkCreateSamplerYcbcrConversion");
4092}
4093
4094bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4095 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4096 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4097 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4098 "vkCreateSamplerYcbcrConversionKHR");
4099}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004100
4101bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4102 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4103 bool skip = false;
4104 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4105 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4106
4107 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004108 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4109 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4110 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4111 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4112 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004113 }
4114 return skip;
4115}