blob: f6ae3f96eefb0603cf7378d4c66f4cb487799b08 [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);
157 phys_dev_ext_props.ray_tracing_props = ray_tracing_props;
158 }
159
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700160 if (device_extensions.vk_ext_transform_feedback) {
161 // Get the needed transform feedback limits
162 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
163 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
164 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
165 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
166 }
167
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800168 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
169
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700170 // Save app-enabled features in this device's validation object
171 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200172 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
173 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
174 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
175 if (features2) {
176 tmp_features2_state.features = features2->features;
177 } else if (pCreateInfo->pEnabledFeatures) {
178 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700179 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200180 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700181 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200182 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700183 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200184 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700185}
186
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700187bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500188 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600189 bool skip = false;
190
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200191 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
192 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
193 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600194 }
195
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200196 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
197 skip |=
198 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
199 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
200 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
201 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600202 }
203
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200204 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700205 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
206 bool negative_viewport =
207 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200208 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700209 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
210 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
211 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200212 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600213 }
214
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600215 {
216 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
217 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
218 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700219 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
220 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
221 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600222 }
223 }
224
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600225 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
226 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600227 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
228 if (features2) {
229 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700230 skip |= LogError(device, kVUID_PVError_InvalidUsage,
231 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
232 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600233 }
234 }
235
Locke77fad1c2019-04-16 13:09:03 -0600236 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
237 if (features2) {
238 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700239 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
240 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
241 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600242 }
243 }
244
245 auto vertex_attribute_divisor_features =
246 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
247 if (vertex_attribute_divisor_features) {
248 bool extension_found = false;
249 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
250 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
251 VK_MAX_EXTENSION_NAME_SIZE)) {
252 extension_found = true;
253 break;
254 }
255 }
256 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700257 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
258 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
259 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600260 }
261 }
262
Tony-LunarG28017bc2020-01-23 14:40:25 -0700263 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
264 if (vulkan_11_features) {
265 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
266 while (current) {
267 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
268 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
269 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
270 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
271 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
272 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700273 skip |= LogError(
274 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700275 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
276 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
277 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
278 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
279 break;
280 }
281 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
282 }
283 }
284
285 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
286 if (vulkan_12_features) {
287 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
288 while (current) {
289 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
290 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
291 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
292 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
293 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
294 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
295 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
296 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
297 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
298 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
299 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
300 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
301 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700302 skip |= LogError(
303 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700304 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
305 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
306 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
307 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
308 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
309 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
310 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
311 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
312 break;
313 }
314 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
315 }
316 }
317
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600318 // Validate pCreateInfo->pQueueCreateInfos
319 if (pCreateInfo->pQueueCreateInfos) {
320 std::unordered_set<uint32_t> set;
321
322 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
323 const uint32_t requested_queue_family = pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex;
324 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700325 skip |=
326 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
327 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
328 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
329 "index value.",
330 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600331 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700332 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
333 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
334 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
335 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600336 } else {
337 set.insert(requested_queue_family);
338 }
339
340 if (pCreateInfo->pQueueCreateInfos[i].pQueuePriorities != nullptr) {
341 for (uint32_t j = 0; j < pCreateInfo->pQueueCreateInfos[i].queueCount; ++j) {
342 const float queue_priority = pCreateInfo->pQueueCreateInfos[i].pQueuePriorities[j];
343 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700344 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
345 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
346 "] (=%f) is not between 0 and 1 (inclusive).",
347 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600348 }
349 }
350 }
351 }
352 }
353
354 return skip;
355}
356
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500357bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700358 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700359 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
360 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
361 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600362 }
363
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700364 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600365}
366
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700367bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500368 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100369 bool skip = false;
370
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600371 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700372 skip |=
373 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600374
375 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
376 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
377 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
378 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700379 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
380 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
381 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600382 }
383
384 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
385 // queueFamilyIndexCount uint32_t values
386 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700387 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
388 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
389 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
390 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600391 }
392 }
393
394 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
395 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
396 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
397 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700398 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
399 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
400 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600401 }
402 }
403
404 return skip;
405}
406
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700407bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500408 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600409 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600410
411 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600412 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
413 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
414 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
415 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700416 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
417 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
418 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600419 }
420
421 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
422 // queueFamilyIndexCount uint32_t values
423 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700424 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
425 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
426 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
427 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 }
429 }
430
Dave Houlton413a6782018-05-22 13:01:54 -0600431 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700432 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600433 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700434 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600435 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600437
Dave Houlton413a6782018-05-22 13:01:54 -0600438 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700439 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600440 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700441 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600442
Dave Houlton130c0212018-01-29 13:39:56 -0700443 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700444 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
445 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700446 skip |= LogError(
447 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600448 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
449 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700450 }
451
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100453 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
454 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700455 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
456 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
457 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600458 }
459
460 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100461 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
462 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700463 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
464 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
465 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
466 ") are not equal.",
467 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100468 }
469
470 if (pCreateInfo->arrayLayers < 6) {
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->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
474 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100475 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600476 }
477
478 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700479 skip |= LogError(
480 device, "VUID-VkImageCreateInfo-imageType-00957",
481 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600482 }
483 }
484
Dave Houlton130c0212018-01-29 13:39:56 -0700485 // 3D image may have only 1 layer
486 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700487 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
488 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700489 }
490
491 // If multi-sample, validate type, usage, tiling and mip levels.
492 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
493 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600494 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700495 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
496 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700497 }
498
499 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
500 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
501 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
502 // At least one of the legal attachment bits must be set
503 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700504 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
505 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700506 }
507 // No flags other than the legal attachment bits may be set
508 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
509 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700510 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
511 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700512 }
513 }
514
Jeff Bolzef40fec2018-09-01 22:04:34 -0500515 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600516 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500517 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600518 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
519 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500520 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600521 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700522 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
523 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
524 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 }
526
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600527 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700528 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
529 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
530 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600531 }
532
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700533 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700534 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
535 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
536 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100537 }
538
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600539 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
540 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
541 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
542 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
544 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
545 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 }
547
548 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
549 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
550 // Linear tiling is unsupported
551 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 skip |= LogError(device, kVUID_PVError_InvalidUsage,
553 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
554 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555 }
556
557 // Sparse 1D image isn't valid
558 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
560 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600561 }
562
563 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700564 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700565 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
566 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
567 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600568 }
569
570 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700571 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700572 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
573 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
574 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600575 }
576
577 // Multi-sample 2D image when device doesn't support it
578 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700579 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600580 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700581 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
582 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
583 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700584 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600585 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700586 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
587 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
588 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700589 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700591 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
592 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
593 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700594 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
597 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
598 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 }
600 }
601 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500602
Jeff Bolz9af91c52018-09-01 21:53:57 -0500603 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
604 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700605 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
606 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
607 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500608 }
609 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
611 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
612 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500613 }
614 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700615 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
616 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
617 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500618 }
619 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500620
621 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600622 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
624 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
625 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500626 }
627
Dave Houlton142c4cb2018-10-17 15:04:41 -0600628 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
630 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
631 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
632 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500633 }
634
Dave Houlton142c4cb2018-10-17 15:04:41 -0600635 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
637 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
638 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
639 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500640 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600641 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700642 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
643 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
644 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
645 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500646 }
647 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500648
649 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
650 if (image_stencil_struct != nullptr) {
651 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
652 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
653 // No flags other than the legal attachment bits may be set
654 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
655 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700656 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
657 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
658 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
659 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500660 }
661 }
662
663 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
664 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
665 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
666 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700667 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
668 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
669 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
670 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500671 }
672
673 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
674 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 LogError(device, "VUID-VkImageCreateInfo-format-02537",
676 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
677 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
678 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500679 }
680 }
681
682 if (!physical_device_features.shaderStorageImageMultisample &&
683 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
684 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
685 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700686 LogError(device, "VUID-VkImageCreateInfo-format-02538",
687 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
688 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
689 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500690 }
691
692 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
693 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(
695 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500696 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
697 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
698 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
699 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
700 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(
702 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500703 "vkCreateImage(): Depth-stencil image in which usage does not include "
704 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
705 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
706 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
707 }
708
709 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
710 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700711 skip |= LogError(
712 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500713 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
714 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
715 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
716 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
717 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(
719 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500720 "vkCreateImage(): Depth-stencil image in which usage does not include "
721 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
722 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
723 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
724 }
725 }
726 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700727
728 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
729 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
730 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
731 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
732 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
733 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600734 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500735
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600736 return skip;
737}
738
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600739bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100741 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100742
743 // Note: for numerical correctness
744 // - float comparisons should expect NaN (comparison always false).
745 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
746
747 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700748 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100749 if (v1_f <= 0.0f) return true;
750
751 float intpart;
752 const float fract = modff(v1_f, &intpart);
753
754 assert(std::numeric_limits<float>::radix == 2);
755 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
756 if (intpart >= u32_max_plus1) return false;
757
758 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
759 if (v1_u32 < v2_u32)
760 return true;
761 else if (v1_u32 == v2_u32 && fract == 0.0f)
762 return true;
763 else
764 return false;
765 };
766
767 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
768 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
769 return (v1_f <= v2_f);
770 };
771
772 // width
773 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700774 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100775
776 if (!(viewport.width > 0.0f)) {
777 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700778 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
779 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100780 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
781 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700782 skip |= LogError(object, "VUID-VkViewport-width-01771",
783 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
784 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100785 } 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 -0700786 skip |= LogWarning(object, kVUID_PVError_NONE,
787 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
788 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
789 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100790 }
791
792 // height
793 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -0700794 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700795 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100796
797 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
798 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700799 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
800 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100801 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
802 height_healthy = false;
803
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700804 skip |= LogError(object, "VUID-VkViewport-height-01773",
805 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
806 ").",
807 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100808 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
809 height_healthy = false;
810
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700811 skip |= LogWarning(
812 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +0100813 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600814 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600815 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100816 }
817
818 // x
819 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700820 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100821 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 skip |= LogError(object, "VUID-VkViewport-x-01774",
823 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
824 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100825 }
826
827 // x + width
828 if (x_healthy && width_healthy) {
829 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700830 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700831 skip |= LogError(
832 object, "VUID-VkViewport-x-01232",
833 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
834 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
835 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100836 }
837 }
838
839 // y
840 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700841 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100842 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700843 skip |= LogError(object, "VUID-VkViewport-y-01775",
844 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
845 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700846 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100847 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 skip |= LogError(object, "VUID-VkViewport-y-01776",
849 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
850 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100851 }
852
853 // y + height
854 if (y_healthy && height_healthy) {
855 const float boundary = viewport.y + viewport.height;
856
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700857 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700858 skip |= LogError(object, "VUID-VkViewport-y-01233",
859 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
860 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
861 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700862 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600863 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700864 LogError(object, "VUID-VkViewport-y-01777",
865 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
866 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
867 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100868 }
869 }
870
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700871 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100872 // minDepth
873 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600875
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
877 "[0.0, 1.0] range.",
878 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100879 }
880
881 // maxDepth
882 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -0600884
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
886 "[0.0, 1.0] range.",
887 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100888 }
889 }
890
891 return skip;
892}
893
Dave Houlton142c4cb2018-10-17 15:04:41 -0600894struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500895 VkShadingRatePaletteEntryNV shadingRate;
896 uint32_t width;
897 uint32_t height;
898};
899
900// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -0600901static SampleOrderInfo sampleOrderInfos[] = {
902 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
903 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
904 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
905 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
906 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
907 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -0500908};
909
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500910bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500911 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500912
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500913 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -0500914 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -0500915 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -0500916 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500917 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -0500918 break;
919 }
920 }
921
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500922 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
924 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
925 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500926 return skip;
927 }
928
Dave Houlton142c4cb2018-10-17 15:04:41 -0600929 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700930 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700931 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
932 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
933 ") must "
934 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
935 "is set in framebufferNoAttachmentsSampleCounts.",
936 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500937 }
938
Jeff Bolz9af91c52018-09-01 21:53:57 -0500939 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700940 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
941 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
942 ") must "
943 "be equal to the product of sampleCount (=%" PRIu32
944 "), the fragment width for shadingRate "
945 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
946 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500947 }
948
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700949 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700950 skip |= LogError(
951 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600952 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
953 ") must "
954 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700955 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500956 }
Jeff Bolz9af91c52018-09-01 21:53:57 -0500957
958 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500959 // the first width*height*sampleCount bits to all be set. Note: There is no
960 // guarantee that 64 bits is enough, but practically it's unlikely for an
961 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700962 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -0500963 uint64_t sampleLocationsMask = 0;
964 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
965 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
966 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700967 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
968 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500969 }
970 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
972 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500973 }
974 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700975 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
976 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500977 }
978 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
979 sampleLocationsMask |= 1ULL << idx;
980 }
981
982 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
983 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700984 skip |= LogError(
985 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -0600986 "The array pSampleLocations must contain exactly one entry for "
987 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500988 }
989
990 return skip;
991}
992
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700993bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
994 uint32_t createInfoCount,
995 const VkGraphicsPipelineCreateInfo *pCreateInfos,
996 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500997 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600998 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600999
1000 if (pCreateInfos != nullptr) {
1001 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001002 bool has_dynamic_viewport = false;
1003 bool has_dynamic_scissor = false;
1004 bool has_dynamic_line_width = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001005 bool has_dynamic_viewport_w_scaling_nv = false;
1006 bool has_dynamic_discard_rectangle_ext = false;
1007 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001008 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001009 bool has_dynamic_shading_rate_palette_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001010 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001011 if (pCreateInfos[i].pDynamicState != nullptr) {
1012 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1013 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1014 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
1015 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) has_dynamic_viewport = true;
1016 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) has_dynamic_scissor = true;
1017 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) has_dynamic_line_width = true;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001018 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) has_dynamic_viewport_w_scaling_nv = true;
1019 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) has_dynamic_discard_rectangle_ext = true;
1020 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) has_dynamic_sample_locations_ext = true;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001021 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) has_dynamic_exclusive_scissor_nv = true;
Dave Houlton142c4cb2018-10-17 15:04:41 -06001022 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV)
1023 has_dynamic_shading_rate_palette_nv = true;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001024 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) has_dynamic_line_stipple = true;
Petr Kraus299ba622017-11-24 03:09:03 +01001025 }
1026 }
1027
Peter Chen85366392019-05-14 15:20:11 -04001028 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1029 if ((feedback_struct != nullptr) &&
1030 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001031 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1032 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1033 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1034 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1035 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001036 }
1037
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001038 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001039
1040 // Collect active stages
1041 uint32_t active_shaders = 0;
1042 for (uint32_t stages = 0; stages < pCreateInfos[i].stageCount; stages++) {
Spencer Fricked84808f2020-01-20 06:08:01 -08001043 active_shaders |= pCreateInfos[i].pStages[stages].stage;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001044 }
1045
1046 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1047 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1048 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1049 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1050 pCreateInfos[i].pTessellationState,
1051 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1052 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1053
1054 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1055 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1056
1057 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1058 "VkPipelineTessellationDomainOriginStateCreateInfo",
1059 pCreateInfos[i].pTessellationState->pNext,
1060 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1061 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001062 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1063 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001064
1065 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1066 pCreateInfos[i].pTessellationState->flags,
1067 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1068 }
1069
1070 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1071 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1072 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1073 pCreateInfos[i].pInputAssemblyState,
1074 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1075 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1076
1077 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1078 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001079 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001080
1081 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1082 pCreateInfos[i].pInputAssemblyState->flags,
1083 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1084
1085 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1086 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1087 pCreateInfos[i].pInputAssemblyState->topology,
1088 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1089
1090 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1091 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1092 }
1093
1094 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001095 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001096
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001097 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001098 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1099 "vkCreateGraphicsPipelines: pararameter "
1100 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1101 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001102 }
1103
1104 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1105 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1106 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1107 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1108 pCreateInfos[i].pVertexInputState->pNext, 1,
1109 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001110 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1111 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001112 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1113 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001114 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001115 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1116 skip |=
1117 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1118 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1119 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1120 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1121 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1122
1123 skip |= validate_array(
1124 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1125 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1126 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1127 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1128
1129 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1130 for (uint32_t vertexBindingDescriptionIndex = 0;
1131 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1132 ++vertexBindingDescriptionIndex) {
1133 skip |= validate_ranged_enum(
1134 "vkCreateGraphicsPipelines",
1135 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1136 AllVkVertexInputRateEnums,
1137 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1138 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1139 }
1140 }
1141
1142 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1143 for (uint32_t vertexAttributeDescriptionIndex = 0;
1144 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1145 ++vertexAttributeDescriptionIndex) {
1146 skip |= validate_ranged_enum(
1147 "vkCreateGraphicsPipelines",
1148 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1149 AllVkFormatEnums,
1150 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1151 "VUID-VkVertexInputAttributeDescription-format-parameter");
1152 }
1153 }
1154
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001155 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001156 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1157 "vkCreateGraphicsPipelines: pararameter "
1158 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1159 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1160 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001161 }
1162
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001163 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001164 skip |=
1165 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1166 "vkCreateGraphicsPipelines: pararameter "
1167 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1168 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1169 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001170 }
1171
1172 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001173 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1174 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001175 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1176 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001177 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1178 "vkCreateGraphicsPipelines: parameter "
1179 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1180 "(%" PRIu32 ") is not distinct.",
1181 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001182 }
1183 vertex_bindings.insert(vertex_bind_desc.binding);
1184
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001185 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001186 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1187 "vkCreateGraphicsPipelines: parameter "
1188 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1189 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1190 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001191 }
1192
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001193 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001194 skip |=
1195 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1196 "vkCreateGraphicsPipelines: parameter "
1197 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1198 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1199 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001200 }
1201 }
1202
Peter Kohautc7d9d392018-07-15 00:34:07 +02001203 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001204 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1205 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001206 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1207 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001208 skip |= LogError(
1209 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001210 "vkCreateGraphicsPipelines: parameter "
1211 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1212 i, d, vertex_attrib_desc.location);
1213 }
1214 attribute_locations.insert(vertex_attrib_desc.location);
1215
1216 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1217 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001218 skip |= LogError(
1219 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001220 "vkCreateGraphicsPipelines: parameter "
1221 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1222 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1223 i, d, vertex_attrib_desc.binding, i);
1224 }
1225
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001226 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001227 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1228 "vkCreateGraphicsPipelines: parameter "
1229 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1230 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1231 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001232 }
1233
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001234 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001235 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1236 "vkCreateGraphicsPipelines: parameter "
1237 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1238 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1239 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001240 }
1241
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001242 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001243 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1244 "vkCreateGraphicsPipelines: parameter "
1245 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1246 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1247 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001248 }
1249 }
1250 }
1251
1252 if (pCreateInfos[i].pStages != nullptr) {
1253 bool has_control = false;
1254 bool has_eval = false;
1255
1256 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1257 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1258 has_control = true;
1259 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1260 has_eval = true;
1261 }
1262 }
1263
1264 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1265 if (has_control && has_eval) {
1266 if (pCreateInfos[i].pTessellationState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001267 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1268 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1269 "shader stage and a tessellation evaluation shader stage, "
1270 "pCreateInfos[%d].pTessellationState must not be NULL.",
1271 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001272 } else {
Lockee04009e2019-03-08 12:22:35 -07001273 const VkStructureType allowed_type =
1274 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001275 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001276 "vkCreateGraphicsPipelines",
Lockee04009e2019-03-08 12:22:35 -07001277 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1278 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
sfricke-samsung32a27362020-02-28 09:06:42 -08001279 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1280 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001281
1282 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001283 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001284 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001285 pCreateInfos[i].pTessellationState->flags,
1286 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001287
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001288 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001289 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001290 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1291 "vkCreateGraphicsPipelines: invalid parameter "
1292 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1293 "should be >0 and <=%u.",
1294 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1295 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001296 }
1297 }
1298 }
1299 }
1300
1301 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1302 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1303 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1304 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001305 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1306 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1307 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1308 "].pViewportState (=NULL) is not a valid pointer.",
1309 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001310 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001311 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1312
1313 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001314 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1315 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1316 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1317 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001318 }
1319
Petr Krausa6103552017-11-16 21:21:58 +01001320 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1321 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001322 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1323 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001324 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1325 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001326 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001327 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001328 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001329 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001330 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001331 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1332 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001333 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001334 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1335 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001336
1337 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001338 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001339 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001340 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001341
Dave Houlton142c4cb2018-10-17 15:04:41 -06001342 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1343 pCreateInfos[i].pViewportState->pNext);
1344 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1345 pCreateInfos[i].pViewportState->pNext);
1346 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1347 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001348 const auto vp_swizzle_struct =
1349 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001350 const auto vp_w_scaling_struct =
1351 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001352
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001353 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001354 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001355 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1356 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1357 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1358 ") is not 1.",
1359 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001360 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001361
Petr Krausa6103552017-11-16 21:21:58 +01001362 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001363 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1364 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1365 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1366 ") is not 1.",
1367 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001368 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001369
Dave Houlton142c4cb2018-10-17 15:04:41 -06001370 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1371 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001372 skip |= LogError(
1373 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1374 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1375 "disabled, but pCreateInfos[%" PRIu32
1376 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1377 ") is not 1.",
1378 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001379 }
1380
Jeff Bolz9af91c52018-09-01 21:53:57 -05001381 if (shading_rate_image_struct &&
1382 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001383 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1384 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1385 "disabled, but pCreateInfos[%" PRIu32
1386 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1387 ") is neither 0 nor 1.",
1388 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001389 }
1390
Petr Krausa6103552017-11-16 21:21:58 +01001391 } else { // multiViewport enabled
1392 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001393 skip |= LogError(
1394 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001395 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001396 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1398 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1399 "].pViewportState->viewportCount (=%" PRIu32
1400 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1401 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001402 }
Petr Krausa6103552017-11-16 21:21:58 +01001403
1404 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001405 skip |= LogError(
1406 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001407 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001408 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001409 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1410 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1411 "].pViewportState->scissorCount (=%" PRIu32
1412 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1413 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001414 }
1415 }
1416
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001417 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001418 skip |=
1419 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1420 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1421 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1422 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001423 }
1424
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001425 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001426 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1427 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1428 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1429 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1430 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001431 }
1432
Petr Krausa6103552017-11-16 21:21:58 +01001433 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001434 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1435 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1436 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1437 "].pViewportState->viewportCount (=%" PRIu32 ").",
1438 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001439 }
1440
Dave Houlton142c4cb2018-10-17 15:04:41 -06001441 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001442 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |=
1444 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1445 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1446 ") must be zero or identical to pCreateInfos[%" PRIu32
1447 "].pViewportState->viewportCount (=%" PRIu32 ").",
1448 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001449 }
1450
Dave Houlton142c4cb2018-10-17 15:04:41 -06001451 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001452 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001453 skip |= LogError(
1454 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001455 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1456 "] "
1457 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1458 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1459 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001460 }
1461
Petr Krausa6103552017-11-16 21:21:58 +01001462 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001463 skip |= LogError(
1464 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001465 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1466 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001467 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1468 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001469 }
1470
1471 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001472 skip |= LogError(
1473 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001474 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1475 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001476 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1477 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001478 }
1479
Jeff Bolz3e71f782018-08-29 23:15:45 -05001480 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001481 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1482 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1483 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001484 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1485 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1486 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1487 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1488 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001489 }
1490
Jeff Bolz9af91c52018-09-01 21:53:57 -05001491 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001492 shading_rate_image_struct->viewportCount > 0 &&
1493 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001494 skip |= LogError(
1495 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001496 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001497 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1498 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001499 i, i);
1500 }
1501
Chris Mayer328d8212018-12-11 14:16:18 +01001502 if (vp_swizzle_struct) {
1503 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001504 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1505 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1506 " does "
1507 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1508 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001509 }
1510 }
1511
Petr Krausb3fcdb42018-01-09 22:09:09 +01001512 // validate the VkViewports
1513 if (!has_dynamic_viewport && viewport_state.pViewports) {
1514 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1515 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001516 const char *fn_name = "vkCreateGraphicsPipelines";
1517 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1518 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1519 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001520 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001521 }
1522 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001523
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001524 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001525 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1526 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1527 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1528 "VK_NV_clip_space_w_scaling extension is not enabled.",
1529 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001530 }
1531
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001532 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001533 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1534 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1535 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1536 "VK_EXT_discard_rectangles extension is not enabled.",
1537 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001538 }
1539
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001540 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001541 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1542 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1543 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1544 "VK_EXT_sample_locations extension is not enabled.",
1545 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001546 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001547
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001548 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001549 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1550 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1551 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1552 "VK_NV_scissor_exclusive extension is not enabled.",
1553 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001554 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001555
1556 if (coarse_sample_order_struct &&
1557 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1558 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001559 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1560 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1561 "] "
1562 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1563 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1564 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001565 }
1566
1567 if (coarse_sample_order_struct) {
1568 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001569 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001570 }
1571 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001572
1573 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1574 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1576 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1577 "] "
1578 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1579 ") "
1580 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1581 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001582 }
1583 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(
1585 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001586 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1587 "] "
1588 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1589 i);
1590 }
1591 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001592 }
1593
1594 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001595 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1596 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1597 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1598 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001599 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001600 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1601 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1602 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001603 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001604 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001605 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001607 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001608 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001609 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001610 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1611 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001612
1613 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001614 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001615 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001616 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001617
1618 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001619 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001620 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1621 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1622
1623 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001624 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001625 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1626 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001627 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001628 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001629
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001630 skip |= validate_flags(
1631 "vkCreateGraphicsPipelines",
1632 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1633 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001634 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001635
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001636 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001637 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001638 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1639 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1640
1641 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001642 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001643 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1644 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1645
1646 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001647 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1648 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1649 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1650 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001651 }
John Zulauf7acac592017-11-06 11:15:53 -07001652 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001653 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001654 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1655 "vkCreateGraphicsPipelines(): parameter "
1656 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1657 i);
John Zulauf7acac592017-11-06 11:15:53 -07001658 }
1659 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1660 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1661 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001662 skip |= LogError(
1663 device,
1664
Dave Houlton413a6782018-05-22 13:01:54 -06001665 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001666 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001667 }
1668 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001669
1670 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1671 pCreateInfos[i].pRasterizationState->pNext);
1672
1673 if (line_state) {
1674 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1675 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1676 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1677 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001678 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1679 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1680 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1681 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001682 }
1683 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1684 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001685 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1686 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1687 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1688 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001689 }
1690 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1691 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001692 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1693 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1694 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1695 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001696 }
1697 }
1698 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1699 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1700 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001701 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1702 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1703 "range [1,256].",
1704 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001705 }
1706 }
1707 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001708 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001709 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1710 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001711 skip |=
1712 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1713 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1714 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1715 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001716 }
1717 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1718 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001719 skip |=
1720 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1721 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1722 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1723 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001724 }
1725 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1726 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001727 skip |=
1728 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1729 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1730 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1731 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001732 }
1733 if (line_state->stippledLineEnable) {
1734 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1735 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001736 skip |=
1737 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1738 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1739 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1740 "stippledRectangularLines feature.",
1741 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001742 }
1743 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1744 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001745 skip |=
1746 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1747 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1748 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1749 "stippledBresenhamLines feature.",
1750 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001751 }
1752 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1753 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001754 skip |=
1755 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1756 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1757 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1758 "stippledSmoothLines feature.",
1759 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001760 }
1761 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1762 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001763 skip |=
1764 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1765 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1766 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1767 "stippledRectangularLines and strictLines features.",
1768 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001769 }
1770 }
1771 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001772 }
1773
Petr Krause91f7a12017-12-14 20:57:36 +01001774 bool uses_color_attachment = false;
1775 bool uses_depthstencil_attachment = false;
1776 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001777 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001778 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1779 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001780 const auto &subpasses_uses = subpasses_uses_it->second;
1781 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1782 uses_color_attachment = true;
1783 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1784 uses_depthstencil_attachment = true;
1785 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001786 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001787 }
1788
1789 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001790 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001791 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001792 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001793 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001794 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001795
1796 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001797 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001798 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001799 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001800
1801 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001802 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001803 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1804 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1805
1806 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001807 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001808 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1809 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1810
1811 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001812 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001813 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1814 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001815 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001816
1817 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001818 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001819 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1820 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1821
1822 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001823 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001824 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1825 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1826
1827 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001828 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001829 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1830 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001831 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001832
1833 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001834 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1836 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001837 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001838
1839 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001840 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001841 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1842 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001843 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001844
1845 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001846 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001847 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1848 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001849 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001850
1851 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001852 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001853 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1854 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001855 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001856
1857 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001858 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001859 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
1860 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001861 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001862
1863 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001864 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001865 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
1866 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001867 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001868
1869 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001870 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001871 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
1872 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001873 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001874
1875 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001876 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1877 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
1878 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
1879 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001880 }
1881 }
1882
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001883 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
1884 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
1885
Petr Krause91f7a12017-12-14 20:57:36 +01001886 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001887 skip |= validate_struct_type("vkCreateGraphicsPipelines",
1888 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
1889 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1890 pCreateInfos[i].pColorBlendState,
1891 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
1892 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
1893
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001894 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001895 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06001896 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
1897 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
1898 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001899 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001900 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
1901 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001902
1903 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001904 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001905 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001906 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001907
1908 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001909 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001910 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
1911 pCreateInfos[i].pColorBlendState->logicOpEnable);
1912
1913 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001914 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001915 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
1916 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001917 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06001918 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001919
1920 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
1921 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
1922 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001923 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001924 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
1925 ParameterName::IndexVector{i, attachmentIndex}),
1926 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
1927
1928 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001929 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001930 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
1931 ParameterName::IndexVector{i, attachmentIndex}),
1932 "VkBlendFactor", AllVkBlendFactorEnums,
1933 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001934 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001935
1936 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001937 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001938 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
1939 ParameterName::IndexVector{i, attachmentIndex}),
1940 "VkBlendFactor", AllVkBlendFactorEnums,
1941 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001942 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001943
1944 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001945 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001946 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
1947 ParameterName::IndexVector{i, attachmentIndex}),
1948 "VkBlendOp", AllVkBlendOpEnums,
1949 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001950 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001951
1952 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001953 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001954 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
1955 ParameterName::IndexVector{i, attachmentIndex}),
1956 "VkBlendFactor", AllVkBlendFactorEnums,
1957 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001958 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001959
1960 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001961 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001962 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
1963 ParameterName::IndexVector{i, attachmentIndex}),
1964 "VkBlendFactor", AllVkBlendFactorEnums,
1965 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06001966 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001967
1968 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001969 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001970 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
1971 ParameterName::IndexVector{i, attachmentIndex}),
1972 "VkBlendOp", AllVkBlendOpEnums,
1973 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001974 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001975
1976 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001977 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001978 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
1979 ParameterName::IndexVector{i, attachmentIndex}),
1980 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
1981 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02001982 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001983 }
1984 }
1985
1986 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001987 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1988 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
1989 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
1990 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001991 }
1992
1993 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
1994 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
1995 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001996 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001997 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06001998 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
1999 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002000 }
2001 }
2002 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002003
Petr Kraus9752aae2017-11-24 03:05:50 +01002004 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2005 if (pCreateInfos[i].basePipelineIndex != -1) {
2006 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002007 skip |=
2008 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2009 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2010 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2011 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 }
2013 }
2014
Petr Kraus9752aae2017-11-24 03:05:50 +01002015 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2016 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002017 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2018 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2019 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2020 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002021 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002022 } else {
2023 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002024 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2025 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2026 "index into the pCreateInfos array, of size %d.",
2027 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002028 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002029 }
2030 }
2031
Petr Kraus9752aae2017-11-24 03:05:50 +01002032 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002033 if (!device_extensions.vk_nv_fill_rectangle) {
2034 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2035 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002036 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2037 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2038 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2039 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002040 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2041 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002042 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2043 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2044 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2045 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002046 }
2047 } else {
2048 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2049 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2050 (physical_device_features.fillModeNonSolid == false)) {
2051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002052 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2053 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2054 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2055 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002056 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 }
Petr Kraus299ba622017-11-24 03:09:03 +01002058
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002059 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002060 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002061 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2062 "The line width state is static (pCreateInfos[%" PRIu32
2063 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2064 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2065 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2066 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002067 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068 }
2069
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002071 skip |= validate_string("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002072 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002073 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[j].pName);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002074 }
2075 }
2076 }
2077
2078 return skip;
2079}
2080
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002081bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2082 uint32_t createInfoCount,
2083 const VkComputePipelineCreateInfo *pCreateInfos,
2084 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002085 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002086 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002087 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002088 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002090 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002091 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2092 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002093 skip |=
2094 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2095 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2096 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2097 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002098 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002099
2100 // Make sure compute stage is selected
2101 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002102 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2103 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2104 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002105 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002106 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002107 return skip;
2108}
2109
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002110bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002111 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002112 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002113
2114 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002115 const auto &features = physical_device_features;
2116 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002117
John Zulauf71968502017-10-26 13:51:15 -06002118 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2119 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002120 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2121 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2122 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2123 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002124 }
2125
2126 // Anistropy cannot be enabled in sampler unless enabled as a feature
2127 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002128 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2129 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2130 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002131 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002132 }
John Zulauf71968502017-10-26 13:51:15 -06002133
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002134 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2135 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002136 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2137 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2138 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2139 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002140 }
2141 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002142 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2143 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2144 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2145 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002146 }
2147 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002148 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2149 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2150 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2151 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002152 }
2153 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2154 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2155 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2156 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002157 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2158 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2159 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2160 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2161 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2162 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002163 }
2164 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002165 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2166 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2167 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002168 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002169 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002170 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2171 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2172 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002173 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002174 }
2175
2176 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2177 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002178 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2179 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 }
2181
2182 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2183 // valid VkBorderColor value
2184 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2185 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2186 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002187 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2188 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189 }
2190
2191 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2192 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002193 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002194 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2195 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2196 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002197 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2199 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2200 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002201 }
John Zulauf275805c2017-10-26 15:34:49 -06002202
2203 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002204 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002205 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2206 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002207 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2208 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2209 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002210 }
2211 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002212
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002213 // Check for valid Lod range
2214 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002215 skip |=
2216 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2217 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002218 }
2219
2220 // Check mipLodBias to device limit
2221 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002222 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2223 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2224 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002225 }
2226
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002227 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2228 if (sampler_conversion != nullptr) {
2229 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2230 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2231 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2232 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002233 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002234 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002235 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2236 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2237 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2238 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2239 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2240 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2241 }
2242 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 }
2244
2245 return skip;
2246}
2247
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002248bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2249 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2250 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002251 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002252 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253
2254 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2255 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2256 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2257 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
2258 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
2259 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
2260 // valid VkSampler handles
2261 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2262 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2263 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2264 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2265 ++descriptor_index) {
2266 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002267 skip |= LogError(device, kVUID_PVError_RequiredParameter,
2268 "vkCreateDescriptorSetLayout: required parameter "
2269 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2270 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002271 }
2272 }
2273 }
2274
2275 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2276 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2277 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002278 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2279 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2280 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2281 "values.",
2282 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 }
2284 }
2285 }
2286 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002287 return skip;
2288}
2289
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002290bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2291 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002292 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2294 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2295 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002296 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2297 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298}
2299
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002300bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2301 const VkWriteDescriptorSet *pDescriptorWrites,
2302 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002304
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 if (pDescriptorWrites != NULL) {
2306 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2307 // descriptorCount must be greater than 0
2308 if (pDescriptorWrites[i].descriptorCount == 0) {
2309 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002310 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2311 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002312 }
2313
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002314 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2315 if (validateDstSet) {
2316 // dstSet must be a valid VkDescriptorSet handle
2317 skip |= validate_required_handle(vkCallingFunction,
2318 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2319 pDescriptorWrites[i].dstSet);
2320 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321
2322 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2323 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2324 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2325 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2326 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2327 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2328 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2329 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2330 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2332 "%s(): if pDescriptorWrites[%d].descriptorType is "
2333 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2334 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2335 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2336 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2338 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2339 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2340 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2341 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2342 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002343 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002344 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2345 ParameterName::IndexVector{i, descriptor_index}),
2346 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002347 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2349 ParameterName::IndexVector{i, descriptor_index}),
2350 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002351 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002352 }
2353 }
2354 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2355 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2356 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2357 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2358 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2359 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2360 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2361 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002362 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2363 "%s(): if pDescriptorWrites[%d].descriptorType is "
2364 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2365 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2366 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2367 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002368 } else {
2369 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002370 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002371 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2372 ParameterName::IndexVector{i, descriptorIndex}),
2373 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2374 }
2375 }
2376 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2377 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2378 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2379 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2380 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002381 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2382 "%s(): if pDescriptorWrites[%d].descriptorType is "
2383 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2384 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2385 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002386 } else {
2387 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2388 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002389 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002390 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2391 ParameterName::IndexVector{i, descriptor_index}),
2392 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2393 }
2394 }
2395 }
2396
2397 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2398 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002399 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002400 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2401 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2402 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002403 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002404 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2405 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2406 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2407 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002408 }
2409 }
2410 }
2411 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2412 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002413 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002414 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2415 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2416 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002417 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002418 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2419 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2420 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2421 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002422 }
2423 }
2424 }
2425 }
2426 }
2427 }
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002428
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002429 return skip;
2430}
2431
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002432bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2433 const VkWriteDescriptorSet *pDescriptorWrites,
2434 uint32_t descriptorCopyCount,
2435 const VkCopyDescriptorSet *pDescriptorCopies) const {
2436 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2437}
2438
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002439bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002440 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002441 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002442 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2443}
2444
2445bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002446 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002447 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002448 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2449}
2450
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002451bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2452 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002453 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002455
2456 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2457 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2458 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002459 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2460 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 return skip;
2462}
2463
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002464bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002465 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002467
2468 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2469 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002470 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2471
Petr Krause7bb9e82019-08-11 21:34:43 +02002472 // Implicit VUs
2473 // validate only sType here; pointer has to be validated in core_validation
2474 const bool kNotRequired = false;
2475 const char *kNoVUID = nullptr;
2476 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2477 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2478 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479
Petr Krause7bb9e82019-08-11 21:34:43 +02002480 if (pInfo) {
2481 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2482 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2483 skip |= validate_struct_pnext(
2484 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2485 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002486 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2487 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488
Petr Krause7bb9e82019-08-11 21:34:43 +02002489 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002490
Petr Krause7bb9e82019-08-11 21:34:43 +02002491 // Explicit VUs
2492 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(
2494 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002495 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2496 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002498
2499 if (physical_device_features.inheritedQueries) {
2500 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002501 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002502 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002503 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002504 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002505 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002506 }
2507
2508 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002509 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002510 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002511 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002512 } else { // !pipelineStatisticsQuery
2513 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2514 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515 }
Petr Kraus139757b2019-08-15 17:19:33 +02002516
2517 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2518 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002519 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002520 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2521 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(
2523 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002524 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2525 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2526 }
2527 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002528 }
2529
2530 return skip;
2531}
2532
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002533bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002534 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002536
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002537 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002538 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2540 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2541 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002542 }
2543 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2545 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2546 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002547 }
2548 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002549 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002550 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002551 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2552 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2553 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2554 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002555 }
2556 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002557
2558 if (pViewports) {
2559 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2560 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002561 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002562 skip |= manual_PreCallValidateViewport(
2563 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002564 }
2565 }
2566
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002567 return skip;
2568}
2569
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002570bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002571 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002573
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002576 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2577 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2578 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002579 }
2580 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002581 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2582 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2583 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002584 }
2585 } else { // multiViewport enabled
2586 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002587 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002588 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2589 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2590 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2591 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002592 }
2593 }
2594
Petr Kraus6260f0a2018-02-27 21:15:55 +01002595 if (pScissors) {
2596 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2597 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002598
Petr Kraus6260f0a2018-02-27 21:15:55 +01002599 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002600 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2601 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2602 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002603 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002604
Petr Kraus6260f0a2018-02-27 21:15:55 +01002605 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002606 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2607 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2608 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002609 }
2610
2611 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2612 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002613 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2614 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2615 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2616 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002617 }
2618
2619 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2620 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002621 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2622 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2623 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2624 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002625 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 }
2627 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002628
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002629 return skip;
2630}
2631
Jeff Bolz5c801d12019-10-09 10:38:45 -05002632bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002633 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002634
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002635 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002636 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2637 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002638 }
2639
2640 return skip;
2641}
2642
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002643bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002644 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002645 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002646 if (vertexCount == 0) {
2647 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2648 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002649 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 }
2651
2652 if (instanceCount == 0) {
2653 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2654 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002655 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002656 }
2657 return skip;
2658}
2659
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002660bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002661 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002662 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002663
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002664 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002665 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2666 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 }
2668 return skip;
2669}
2670
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002671bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002672 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002673 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002674 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002675 skip |=
2676 LogError(device, kVUID_PVError_DeviceFeature,
2677 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678 }
2679 return skip;
2680}
2681
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002682bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2683 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002684 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002685 bool skip = false;
2686 for (uint32_t rect = 0; rect < rectCount; rect++) {
2687 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002688 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2689 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002690 }
2691 }
2692 return skip;
2693}
2694
Andrew Fobel3abeb992020-01-20 16:33:22 -05002695bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2696 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2697 VkImageFormatProperties2 *pImageFormatProperties,
2698 const char *apiName) const {
2699 bool skip = false;
2700
2701 if (pImageFormatInfo != nullptr) {
2702 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2703 if (image_stencil_struct != nullptr) {
2704 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2705 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2706 // No flags other than the legal attachment bits may be set
2707 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2708 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002709 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2710 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2711 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2712 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2713 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002714 }
2715 }
2716 }
2717 }
2718
2719 return skip;
2720}
2721
2722bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2723 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2724 VkImageFormatProperties2 *pImageFormatProperties) const {
2725 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2726 "vkGetPhysicalDeviceImageFormatProperties2");
2727}
2728
2729bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2730 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2731 VkImageFormatProperties2 *pImageFormatProperties) const {
2732 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2733 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2734}
2735
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002736bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2737 VkImageLayout srcImageLayout, VkImage dstImage,
2738 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002739 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002740 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002741
Dave Houltonf5217612018-02-02 16:18:52 -07002742 VkImageAspectFlags legal_aspect_flags =
2743 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 -07002744 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002745 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2746 }
2747
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002749 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002750 skip |= LogError(
2751 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002752 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753 }
Dave Houltonf5217612018-02-02 16:18:52 -07002754 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002755 skip |= LogError(
2756 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002757 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002758 }
2759 }
2760 return skip;
2761}
2762
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002763bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2764 VkImageLayout srcImageLayout, VkImage dstImage,
2765 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002766 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002767 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002768
Dave Houltonf5217612018-02-02 16:18:52 -07002769 VkImageAspectFlags legal_aspect_flags =
2770 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 -07002771 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002772 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2773 }
2774
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002776 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777 skip |= LogError(
2778 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002779 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2780 }
Dave Houltonf5217612018-02-02 16:18:52 -07002781 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002782 skip |= LogError(
2783 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002784 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2785 }
2786 }
2787 return skip;
2788}
2789
sfricke-samsung3999ef62020-02-09 17:05:59 -08002790bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
2791 uint32_t regionCount, const VkBufferCopy *pRegions) const {
2792 bool skip = false;
2793
2794 if (pRegions != nullptr) {
2795 for (uint32_t i = 0; i < regionCount; i++) {
2796 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002797 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
2798 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08002799 }
2800 }
2801 }
2802 return skip;
2803}
2804
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002805bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2806 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002807 uint32_t regionCount,
2808 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002810
Dave Houltonf5217612018-02-02 16:18:52 -07002811 VkImageAspectFlags legal_aspect_flags =
2812 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 -07002813 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002814 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2815 }
2816
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002817 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002818 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002819 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
2820 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2821 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 }
2823 }
2824 return skip;
2825}
2826
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002827bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2828 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002829 uint32_t regionCount,
2830 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832
Dave Houltonf5217612018-02-02 16:18:52 -07002833 VkImageAspectFlags legal_aspect_flags =
2834 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 -07002835 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002836 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2837 }
2838
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002840 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002841 LogError(device, kVUID_PVError_UnrecognizedValue,
2842 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2843 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002844 }
2845 }
2846 return skip;
2847}
2848
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002849bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002850 VkDeviceSize dstOffset, VkDeviceSize dataSize,
2851 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002853
2854 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002855 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
2856 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2857 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858 }
2859
2860 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002861 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
2862 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
2863 "), must be greater than zero and less than or equal to 65536.",
2864 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002865 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002866 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
2867 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2868 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002869 }
2870 return skip;
2871}
2872
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002873bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002874 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002875 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876
2877 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002878 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
2879 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
2880 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 }
2882
2883 if (size != VK_WHOLE_SIZE) {
2884 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002885 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002886 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
2887 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002889 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
2890 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002891 }
2892 }
2893 return skip;
2894}
2895
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002896bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002897 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002898 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900
2901 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002902 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2903 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
2904 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
2905 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
2907 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2908 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 }
2910
2911 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
2912 // queueFamilyIndexCount uint32_t values
2913 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002914 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
2915 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
2916 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
2917 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002918 }
2919 }
2920
Dave Houlton413a6782018-05-22 13:01:54 -06002921 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002922 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002923 }
2924
2925 return skip;
2926}
2927
Jeff Bolz5c801d12019-10-09 10:38:45 -05002928bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002929 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002930
2931 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06002932 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
2933 if (present_regions) {
2934 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07002935 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06002936 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
2937 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002938 skip |= LogError(device, kVUID_PVError_InvalidUsage,
2939 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
2940 "extension swapchainCount is %i. These values must be equal.",
2941 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06002942 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002943 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08002944 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
2945 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002946 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
2947 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
2948 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06002949 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002950 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06002952 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 }
2955 }
2956
2957 return skip;
2958}
2959
2960#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002961bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
2962 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
2963 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002964 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965 bool skip = false;
2966
2967 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002968 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
2969 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002970 }
2971
2972 return skip;
2973}
2974#endif // VK_USE_PLATFORM_WIN32_KHR
2975
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002976bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002977 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002978 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02002979 bool skip = false;
2980
2981 if (pCreateInfo) {
2982 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002983 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
2984 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02002985 }
2986
2987 if (pCreateInfo->pPoolSizes) {
2988 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
2989 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002990 skip |= LogError(
2991 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002992 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02002993 }
Jeff Bolze54ae892018-09-08 12:16:29 -05002994 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
2995 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002996 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
2997 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
2998 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
2999 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3000 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003001 }
Petr Krausc8655be2017-09-27 18:56:51 +02003002 }
3003 }
3004 }
3005
3006 return skip;
3007}
3008
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003009bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003010 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003011 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003012
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003013 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003014 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003015 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3016 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3017 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003018 }
3019
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003020 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003021 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003022 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3023 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3024 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003025 }
3026
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003027 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003028 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003029 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3030 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3031 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003032 }
3033
3034 return skip;
3035}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003036
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003037bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003038 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003039 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003040
3041 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003042 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3043 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003044 }
3045 return skip;
3046}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003047
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003048bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3049 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003050 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003051 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003052
3053 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003054 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003055 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003056 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3057 "vkCmdDispatch(): baseGroupX (%" PRIu32
3058 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3059 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003060 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003061 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3062 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3063 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3064 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003065 }
3066
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003067 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003068 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003069 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3070 "vkCmdDispatch(): baseGroupY (%" PRIu32
3071 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3072 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003073 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3075 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3076 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3077 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003078 }
3079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003080 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003081 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003082 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3083 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3084 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3085 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003086 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003087 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3088 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3089 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3090 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003091 }
3092
3093 return skip;
3094}
3095
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003096bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3097 VkPipelineBindPoint pipelineBindPoint,
3098 VkPipelineLayout layout, uint32_t set,
3099 uint32_t descriptorWriteCount,
3100 const VkWriteDescriptorSet *pDescriptorWrites) const {
3101 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3102}
3103
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003104bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3105 uint32_t firstExclusiveScissor,
3106 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003107 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003108 bool skip = false;
3109
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003110 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003111 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003112 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3114 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3115 ") is not 0.",
3116 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003117 }
3118 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003119 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3121 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3122 ") is not 1.",
3123 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003124 }
3125 } else { // multiViewport enabled
3126 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003127 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3129 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3130 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3131 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003132 }
3133 }
3134
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003135 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003136 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3137 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3138 ") must be less than maxViewports (=%" PRIu32 ").",
3139 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003140 }
3141
3142 if (pExclusiveScissors) {
3143 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3144 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3145
3146 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003147 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3148 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3149 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003150 }
3151
3152 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3154 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3155 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003156 }
3157
3158 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3159 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003160 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3161 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3162 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3163 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003164 }
3165
3166 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3167 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003168 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3169 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3170 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3171 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003172 }
3173 }
3174 }
3175
3176 return skip;
3177}
3178
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003179bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3180 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003181 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003182 bool skip = false;
3183 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003184 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3185 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3186 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003187 } else {
3188 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3189 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003190 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3191 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3192 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3193 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003194 }
3195 }
3196
3197 return skip;
3198}
3199
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003200bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3201 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003202 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003203 bool skip = false;
3204
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003205 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003206 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003207 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3209 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3210 ") is not 0.",
3211 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003212 }
3213 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003214 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003215 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3216 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3217 ") is not 1.",
3218 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003219 }
3220 }
3221
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003222 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003223 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3224 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3225 ") must be less than maxViewports (=%" PRIu32 ").",
3226 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003227 }
3228
3229 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003230 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003231 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3232 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3233 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3234 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003235 }
3236
3237 return skip;
3238}
3239
Jeff Bolz5c801d12019-10-09 10:38:45 -05003240bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3241 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3242 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003243 bool skip = false;
3244
Dave Houlton142c4cb2018-10-17 15:04:41 -06003245 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003246 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3247 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3248 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003249 }
3250
3251 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003253 }
3254
3255 return skip;
3256}
3257
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003258bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003259 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003260 bool skip = false;
3261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003263 skip |= LogError(
3264 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003265 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3266 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003267 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003268 }
3269
3270 return skip;
3271}
3272
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003273bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3274 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003275 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003276 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003277 static const int condition_multiples = 0b0011;
3278 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003279 skip |= LogError(
3280 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003281 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003282 }
Lockee1c22882019-06-10 16:02:54 -06003283 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003284 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3285 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3286 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3287 stride);
Lockee1c22882019-06-10 16:02:54 -06003288 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003289 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003290 skip |= LogError(
3291 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3292 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003293 }
3294
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003295 return skip;
3296}
3297
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003298bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3299 VkDeviceSize offset, VkBuffer countBuffer,
3300 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003301 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003302 bool skip = false;
3303
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003304 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3306 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3307 "), is not a multiple of 4.",
3308 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003309 }
3310
3311 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3313 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3314 "), is not a multiple of 4.",
3315 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003316 }
3317
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003318 return skip;
3319}
3320
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003321bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003322 const VkAllocationCallbacks *pAllocator,
3323 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003324 bool skip = false;
3325
3326 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3327 if (pCreateInfo != nullptr) {
3328 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3329 // VkQueryPipelineStatisticFlagBits values
3330 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3331 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003332 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3333 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3334 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3335 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003336 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003337 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003338 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003339}
3340
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003341bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3342 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003343 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003344 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3345 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003346}
3347
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003348void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003349 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3350 VkResult result) {
3351 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003352 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353}
3354
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003355void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003356 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3357 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003358 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003359 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003360 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361}
3362
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003363void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3364 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003365 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003366 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003367 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003368}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003369
3370bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003371 const VkAllocationCallbacks *pAllocator,
3372 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003373 bool skip = false;
3374
3375 if (pAllocateInfo) {
3376 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3377 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003378 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3379 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003380 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003381
3382 VkMemoryAllocateFlags flags = 0;
3383 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3384 if (flags_info) {
3385 flags = flags_info->flags;
3386 }
3387
3388 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3389 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3390 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003391 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3392 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3393 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003394 }
3395
3396#ifdef VK_USE_PLATFORM_WIN32_KHR
3397 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3398#endif
3399 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3400 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3401#ifdef VK_USE_PLATFORM_ANDROID_KHR
3402 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3403#endif
3404
3405 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003406 skip |= LogError(
3407 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003408 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3409 }
3410 if (
3411#ifdef VK_USE_PLATFORM_WIN32_KHR
3412 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3413#endif
3414 (import_memory_fd && import_memory_fd->handleType) ||
3415#ifdef VK_USE_PLATFORM_ANDROID_KHR
3416 (import_memory_ahb && import_memory_ahb->buffer) ||
3417#endif
3418 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003419 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3420 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003421 }
3422 }
3423
3424 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003425 VkBool32 capture_replay = false;
3426 VkBool32 buffer_device_address = false;
3427 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3428 if (vulkan_12_features) {
3429 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3430 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3431 } else {
3432 const auto *bda_features =
3433 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3434 if (bda_features) {
3435 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3436 buffer_device_address = bda_features->bufferDeviceAddress;
3437 }
3438 }
3439 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003440 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3441 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3442 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003443 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003444 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003445 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3446 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003447 }
3448 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003449 }
3450 return skip;
3451}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003452
Jason Macnak192fa0e2019-07-26 15:07:16 -07003453bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003454 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003455 bool skip = false;
3456
3457 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3458 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3459 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003460 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003461 } else {
3462 uint32_t vertex_component_size = 0;
3463 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3464 vertex_component_size = 4;
3465 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3466 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3467 vertex_component_size = 2;
3468 }
3469 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003470 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003471 }
3472 }
3473
3474 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3475 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003476 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003477 } else {
3478 uint32_t index_element_size = 0;
3479 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3480 index_element_size = 4;
3481 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3482 index_element_size = 2;
3483 }
3484 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003485 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003486 }
3487 }
3488 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3489 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003490 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003491 }
3492 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003493 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003494 }
3495 }
3496
3497 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003498 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003499 }
3500
3501 return skip;
3502}
3503
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003504bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3505 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003506 bool skip = false;
3507
3508 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003510 }
3511 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003512 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003513 }
3514
3515 return skip;
3516}
3517
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003518bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3519 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003520 bool skip = false;
3521 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003522 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003523 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003525 }
3526 return skip;
3527}
3528
3529bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003530 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003531 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003532 bool skip = false;
3533 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003534 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3535 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3536 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003537 }
3538 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003539 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3540 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3541 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003542 }
3543 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3544 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3546 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3547 "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 -07003548 }
3549 if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003550 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3551 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3552 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003553 }
3554 if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003555 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3556 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3557 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003558 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003559 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003560 uint64_t total_triangle_count = 0;
3561 for (uint32_t i = 0; i < info.geometryCount; i++) {
3562 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003563
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003564 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003565
Jason Macnak5c954952019-07-09 15:46:12 -07003566 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3567 continue;
3568 }
3569 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3570 }
3571 if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003572 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3573 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3574 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003575 }
3576 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003577 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3578 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3579 for (uint32_t i = 1; i < info.geometryCount; i++) {
3580 const VkGeometryNV &geometry = info.pGeometries[i];
3581 if (geometry.geometryType != first_geometry_type) {
3582 // TODO: update fake VUID below with the real one once it is generated.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003583 skip |= LogError(device, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX",
3584 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3585 "info.pGeometries[0].geometryType.",
3586 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003587 }
3588 }
3589 }
Jason Macnak5c954952019-07-09 15:46:12 -07003590 return skip;
3591}
3592
Ricardo Garciaa4935972019-02-21 17:43:18 +01003593bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3594 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003595 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003596 bool skip = false;
3597
3598 if (pCreateInfo) {
3599 if ((pCreateInfo->compactedSize != 0) &&
3600 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003601 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3602 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3603 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3604 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003605 }
Jason Macnak5c954952019-07-09 15:46:12 -07003606
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003607 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003608 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003609 }
3610
3611 return skip;
3612}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003613
Jeff Bolz5c801d12019-10-09 10:38:45 -05003614bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3615 const VkAccelerationStructureInfoNV *pInfo,
3616 VkBuffer instanceData, VkDeviceSize instanceOffset,
3617 VkBool32 update, VkAccelerationStructureNV dst,
3618 VkAccelerationStructureNV src, VkBuffer scratch,
3619 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003620 bool skip = false;
3621
3622 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003623 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003624 }
3625
3626 return skip;
3627}
3628
3629bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3630 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003631 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003632 bool skip = false;
3633 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003634 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3635 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003636 }
3637 return skip;
3638}
3639
Peter Chen85366392019-05-14 15:20:11 -04003640bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3641 uint32_t createInfoCount,
3642 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3643 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003644 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003645 bool skip = false;
3646
3647 for (uint32_t i = 0; i < createInfoCount; i++) {
3648 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3649 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3651 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3652 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3653 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3654 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04003655 }
3656 }
3657
3658 return skip;
3659}
3660
Mike Schuchardt21638df2019-03-16 10:52:02 -07003661#ifdef VK_USE_PLATFORM_WIN32_KHR
3662bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3663 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003664 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003665 bool skip = false;
3666 if (!device_extensions.vk_khr_swapchain)
3667 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3668 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3669 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3670 if (!device_extensions.vk_khr_surface)
3671 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3672 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3673 skip |=
3674 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3675 if (!device_extensions.vk_ext_full_screen_exclusive)
3676 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3677 skip |= validate_struct_type(
3678 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3679 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3680 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3681 if (pSurfaceInfo != NULL) {
3682 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3683 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3684 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3685
3686 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3687 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3688 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3689 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003690 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
3691 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07003692
3693 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3694 }
3695 return skip;
3696}
3697#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003698
3699bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3700 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003701 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003702 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3703 bool skip = false;
3704 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3705 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3706 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3707 }
3708 return skip;
3709}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003710
3711bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003712 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003713 bool skip = false;
3714
3715 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3717 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003718 }
3719
3720 return skip;
3721}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003722
3723bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003724 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003725 bool skip = false;
3726
3727 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003728 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
3729 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003730 }
3731
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003732 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003733 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003734 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
3735 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003736 }
3737
3738 return skip;
3739}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003740
sfricke-samsung4ada8d42020-02-09 17:43:11 -08003741bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
3742 uint32_t bindingCount, const VkBuffer *pBuffers,
3743 const VkDeviceSize *pOffsets) const {
3744 bool skip = false;
3745 if (firstBinding > device_limits.maxVertexInputBindings) {
3746 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
3747 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
3748 device_limits.maxVertexInputBindings);
3749 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
3750 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
3751 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
3752 "maxVertexInputBindings (%u)",
3753 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
3754 }
3755
3756 return skip;
3757}
3758
Mark Lobodzinski84988402019-09-11 15:27:30 -06003759bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003760 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003761 bool skip = false;
3762 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
3764 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003765 }
3766 return skip;
3767}
3768
3769bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003770 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003771 bool skip = false;
3772 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003773 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
3774 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003775 }
3776 return skip;
3777}
Petr Kraus3d720392019-11-13 02:52:39 +01003778
3779bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
3780 VkSemaphore semaphore, VkFence fence,
3781 uint32_t *pImageIndex) const {
3782 bool skip = false;
3783
3784 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003785 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
3786 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003787 }
3788
3789 return skip;
3790}
3791
3792bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
3793 uint32_t *pImageIndex) const {
3794 bool skip = false;
3795
3796 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003797 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
3798 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003799 }
3800
3801 return skip;
3802}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003803
3804bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
3805 uint32_t firstInstance, VkBuffer counterBuffer,
3806 VkDeviceSize counterBufferOffset,
3807 uint32_t counterOffset, uint32_t vertexStride) const {
3808 bool skip = false;
3809
3810 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 skip |= LogError(
3812 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003813 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
3814 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
3815 }
3816
3817 return skip;
3818}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003819
3820bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
3821 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3822 const VkAllocationCallbacks *pAllocator,
3823 VkSamplerYcbcrConversion *pYcbcrConversion,
3824 const char *apiName) const {
3825 bool skip = false;
3826
3827 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003828 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003829 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
3831 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003832 }
3833 return skip;
3834}
3835
3836bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
3837 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3838 const VkAllocationCallbacks *pAllocator,
3839 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3840 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3841 "vkCreateSamplerYcbcrConversion");
3842}
3843
3844bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
3845 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3846 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3847 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3848 "vkCreateSamplerYcbcrConversionKHR");
3849}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003850
3851bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
3852 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
3853 bool skip = false;
3854 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
3855 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
3856
3857 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003858 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
3859 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
3860 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
3861 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
3862 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08003863 }
3864 return skip;
3865}