blob: 3cc7ee684dfce17d6d4d9c6a97500a5aa43a7df0 [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;
Spencer Fricke8d428882020-03-16 17:23:33 -07001005 bool has_dynamic_depth_bias = false;
1006 bool has_dynamic_blend_constant = false;
1007 bool has_dynamic_depth_bounds = false;
1008 bool has_dynamic_stencil_compare = false;
1009 bool has_dynamic_stencil_write = false;
1010 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001011 bool has_dynamic_viewport_w_scaling_nv = false;
1012 bool has_dynamic_discard_rectangle_ext = false;
1013 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001014 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001015 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001016 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001017 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001018 if (pCreateInfos[i].pDynamicState != nullptr) {
1019 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1020 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1021 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001022 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1023 if (has_dynamic_viewport == true) {
1024 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1025 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1026 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1027 i);
1028 }
1029 has_dynamic_viewport = true;
1030 }
1031 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1032 if (has_dynamic_scissor == true) {
1033 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1034 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1035 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1036 i);
1037 }
1038 has_dynamic_scissor = true;
1039 }
1040 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1041 if (has_dynamic_line_width == true) {
1042 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1043 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1044 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1045 i);
1046 }
1047 has_dynamic_line_width = true;
1048 }
1049 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1050 if (has_dynamic_depth_bias == true) {
1051 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1052 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1053 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1054 i);
1055 }
1056 has_dynamic_depth_bias = true;
1057 }
1058 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1059 if (has_dynamic_blend_constant == true) {
1060 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1061 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1062 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1063 i);
1064 }
1065 has_dynamic_blend_constant = true;
1066 }
1067 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1068 if (has_dynamic_depth_bounds == true) {
1069 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1070 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1071 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1072 i);
1073 }
1074 has_dynamic_depth_bounds = true;
1075 }
1076 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1077 if (has_dynamic_stencil_compare == true) {
1078 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1079 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1080 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1081 i);
1082 }
1083 has_dynamic_stencil_compare = true;
1084 }
1085 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1086 if (has_dynamic_stencil_write == true) {
1087 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1088 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1089 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1090 i);
1091 }
1092 has_dynamic_stencil_write = true;
1093 }
1094 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1095 if (has_dynamic_stencil_reference == true) {
1096 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1097 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1098 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1099 i);
1100 }
1101 has_dynamic_stencil_reference = true;
1102 }
1103 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1104 if (has_dynamic_viewport_w_scaling_nv == true) {
1105 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1106 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1107 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1108 i);
1109 }
1110 has_dynamic_viewport_w_scaling_nv = true;
1111 }
1112 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1113 if (has_dynamic_discard_rectangle_ext == true) {
1114 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1115 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1116 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1117 i);
1118 }
1119 has_dynamic_discard_rectangle_ext = true;
1120 }
1121 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1122 if (has_dynamic_sample_locations_ext == true) {
1123 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1124 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1125 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1126 i);
1127 }
1128 has_dynamic_sample_locations_ext = true;
1129 }
1130 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1131 if (has_dynamic_exclusive_scissor_nv == true) {
1132 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1133 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1134 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1135 i);
1136 }
1137 has_dynamic_exclusive_scissor_nv = true;
1138 }
1139 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1140 if (has_dynamic_shading_rate_palette_nv == true) {
1141 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1142 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1143 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1144 i);
1145 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001146 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001147 }
1148 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1149 if (has_dynamic_viewport_course_sample_order_nv == true) {
1150 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1151 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1152 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1153 i);
1154 }
1155 has_dynamic_viewport_course_sample_order_nv = true;
1156 }
1157 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1158 if (has_dynamic_line_stipple == true) {
1159 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1160 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1161 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1162 i);
1163 }
1164 has_dynamic_line_stipple = true;
1165 }
Petr Kraus299ba622017-11-24 03:09:03 +01001166 }
1167 }
1168
Peter Chen85366392019-05-14 15:20:11 -04001169 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1170 if ((feedback_struct != nullptr) &&
1171 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001172 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1173 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1174 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1175 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1176 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001177 }
1178
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001179 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001180
1181 // Collect active stages
1182 uint32_t active_shaders = 0;
1183 for (uint32_t stages = 0; stages < pCreateInfos[i].stageCount; stages++) {
Spencer Fricked84808f2020-01-20 06:08:01 -08001184 active_shaders |= pCreateInfos[i].pStages[stages].stage;
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001185 }
1186
1187 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1188 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1189 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1190 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1191 pCreateInfos[i].pTessellationState,
1192 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1193 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1194
1195 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1196 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1197
1198 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1199 "VkPipelineTessellationDomainOriginStateCreateInfo",
1200 pCreateInfos[i].pTessellationState->pNext,
1201 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1202 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001203 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1204 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001205
1206 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1207 pCreateInfos[i].pTessellationState->flags,
1208 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1209 }
1210
1211 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1212 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1213 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1214 pCreateInfos[i].pInputAssemblyState,
1215 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1216 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1217
1218 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1219 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001220 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001221
1222 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1223 pCreateInfos[i].pInputAssemblyState->flags,
1224 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1225
1226 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1227 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1228 pCreateInfos[i].pInputAssemblyState->topology,
1229 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1230
1231 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1232 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1233 }
1234
1235 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001236 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001237
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001238 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001239 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1240 "vkCreateGraphicsPipelines: pararameter "
1241 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1242 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001243 }
1244
1245 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1246 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1247 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1248 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1249 pCreateInfos[i].pVertexInputState->pNext, 1,
1250 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001251 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1252 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001253 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1254 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001255 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001256 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1257 skip |=
1258 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1259 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1260 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1261 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1262 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1263
1264 skip |= validate_array(
1265 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1266 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1267 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1268 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1269
1270 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1271 for (uint32_t vertexBindingDescriptionIndex = 0;
1272 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1273 ++vertexBindingDescriptionIndex) {
1274 skip |= validate_ranged_enum(
1275 "vkCreateGraphicsPipelines",
1276 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1277 AllVkVertexInputRateEnums,
1278 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1279 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1280 }
1281 }
1282
1283 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1284 for (uint32_t vertexAttributeDescriptionIndex = 0;
1285 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1286 ++vertexAttributeDescriptionIndex) {
1287 skip |= validate_ranged_enum(
1288 "vkCreateGraphicsPipelines",
1289 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1290 AllVkFormatEnums,
1291 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1292 "VUID-VkVertexInputAttributeDescription-format-parameter");
1293 }
1294 }
1295
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001296 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001297 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1298 "vkCreateGraphicsPipelines: pararameter "
1299 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1300 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1301 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001302 }
1303
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001304 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001305 skip |=
1306 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1307 "vkCreateGraphicsPipelines: pararameter "
1308 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1309 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1310 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001311 }
1312
1313 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001314 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1315 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001316 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1317 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001318 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1319 "vkCreateGraphicsPipelines: parameter "
1320 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1321 "(%" PRIu32 ") is not distinct.",
1322 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001323 }
1324 vertex_bindings.insert(vertex_bind_desc.binding);
1325
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001326 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1328 "vkCreateGraphicsPipelines: parameter "
1329 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1330 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1331 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001332 }
1333
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001334 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001335 skip |=
1336 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1337 "vkCreateGraphicsPipelines: parameter "
1338 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1339 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1340 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001341 }
1342 }
1343
Peter Kohautc7d9d392018-07-15 00:34:07 +02001344 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001345 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1346 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001347 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1348 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001349 skip |= LogError(
1350 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001351 "vkCreateGraphicsPipelines: parameter "
1352 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1353 i, d, vertex_attrib_desc.location);
1354 }
1355 attribute_locations.insert(vertex_attrib_desc.location);
1356
1357 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1358 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001359 skip |= LogError(
1360 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001361 "vkCreateGraphicsPipelines: parameter "
1362 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1363 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1364 i, d, vertex_attrib_desc.binding, i);
1365 }
1366
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001367 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001368 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1369 "vkCreateGraphicsPipelines: parameter "
1370 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1371 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1372 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001373 }
1374
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001375 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001376 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1377 "vkCreateGraphicsPipelines: parameter "
1378 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1379 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1380 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001381 }
1382
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001383 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001384 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1385 "vkCreateGraphicsPipelines: parameter "
1386 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1387 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1388 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001389 }
1390 }
1391 }
1392
1393 if (pCreateInfos[i].pStages != nullptr) {
1394 bool has_control = false;
1395 bool has_eval = false;
1396
1397 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1398 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1399 has_control = true;
1400 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1401 has_eval = true;
1402 }
1403 }
1404
1405 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1406 if (has_control && has_eval) {
1407 if (pCreateInfos[i].pTessellationState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001408 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1409 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1410 "shader stage and a tessellation evaluation shader stage, "
1411 "pCreateInfos[%d].pTessellationState must not be NULL.",
1412 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001413 } else {
Lockee04009e2019-03-08 12:22:35 -07001414 const VkStructureType allowed_type =
1415 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001416 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001417 "vkCreateGraphicsPipelines",
Lockee04009e2019-03-08 12:22:35 -07001418 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1419 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
sfricke-samsung32a27362020-02-28 09:06:42 -08001420 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1421 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001422
1423 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001424 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001425 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001426 pCreateInfos[i].pTessellationState->flags,
1427 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001428
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001429 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001430 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001431 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1432 "vkCreateGraphicsPipelines: invalid parameter "
1433 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1434 "should be >0 and <=%u.",
1435 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1436 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001437 }
1438 }
1439 }
1440 }
1441
1442 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1443 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1444 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1445 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001446 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1447 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1448 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1449 "].pViewportState (=NULL) is not a valid pointer.",
1450 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001451 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001452 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1453
1454 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001455 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1456 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1457 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1458 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001459 }
1460
Petr Krausa6103552017-11-16 21:21:58 +01001461 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1462 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001463 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1464 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001465 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1466 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001467 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001468 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001469 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001470 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001471 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001472 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1473 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001474 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001475 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1476 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001477
1478 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001479 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001480 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001481 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001482
Dave Houlton142c4cb2018-10-17 15:04:41 -06001483 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1484 pCreateInfos[i].pViewportState->pNext);
1485 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1486 pCreateInfos[i].pViewportState->pNext);
1487 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1488 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001489 const auto vp_swizzle_struct =
1490 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001491 const auto vp_w_scaling_struct =
1492 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001493
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001494 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001495 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001496 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1497 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1498 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1499 ") is not 1.",
1500 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001501 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001502
Petr Krausa6103552017-11-16 21:21:58 +01001503 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001504 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1505 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1506 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1507 ") is not 1.",
1508 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001509 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001510
Dave Houlton142c4cb2018-10-17 15:04:41 -06001511 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1512 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001513 skip |= LogError(
1514 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1515 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1516 "disabled, but pCreateInfos[%" PRIu32
1517 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1518 ") is not 1.",
1519 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001520 }
1521
Jeff Bolz9af91c52018-09-01 21:53:57 -05001522 if (shading_rate_image_struct &&
1523 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001524 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1525 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1526 "disabled, but pCreateInfos[%" PRIu32
1527 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1528 ") is neither 0 nor 1.",
1529 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001530 }
1531
Petr Krausa6103552017-11-16 21:21:58 +01001532 } else { // multiViewport enabled
1533 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001534 skip |= LogError(
1535 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001536 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001537 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001538 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1539 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1540 "].pViewportState->viewportCount (=%" PRIu32
1541 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1542 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001543 }
Petr Krausa6103552017-11-16 21:21:58 +01001544
1545 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001546 skip |= LogError(
1547 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001548 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001549 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001550 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1551 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1552 "].pViewportState->scissorCount (=%" PRIu32
1553 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1554 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001555 }
1556 }
1557
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001558 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001559 skip |=
1560 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1561 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1562 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1563 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001564 }
1565
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001566 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001567 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1568 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1569 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1570 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1571 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001572 }
1573
Petr Krausa6103552017-11-16 21:21:58 +01001574 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001575 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1576 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1577 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1578 "].pViewportState->viewportCount (=%" PRIu32 ").",
1579 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001580 }
1581
Dave Houlton142c4cb2018-10-17 15:04:41 -06001582 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001583 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |=
1585 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1586 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1587 ") must be zero or identical to pCreateInfos[%" PRIu32
1588 "].pViewportState->viewportCount (=%" PRIu32 ").",
1589 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001590 }
1591
Dave Houlton142c4cb2018-10-17 15:04:41 -06001592 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001593 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001594 skip |= LogError(
1595 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001596 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1597 "] "
1598 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1599 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1600 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001601 }
1602
Petr Krausa6103552017-11-16 21:21:58 +01001603 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001604 skip |= LogError(
1605 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001606 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1607 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001608 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1609 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001610 }
1611
1612 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001613 skip |= LogError(
1614 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001615 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1616 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001617 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1618 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001619 }
1620
Jeff Bolz3e71f782018-08-29 23:15:45 -05001621 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001622 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1623 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1624 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001625 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1626 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1627 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1628 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1629 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001630 }
1631
Jeff Bolz9af91c52018-09-01 21:53:57 -05001632 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001633 shading_rate_image_struct->viewportCount > 0 &&
1634 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001635 skip |= LogError(
1636 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001637 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001638 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1639 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001640 i, i);
1641 }
1642
Chris Mayer328d8212018-12-11 14:16:18 +01001643 if (vp_swizzle_struct) {
1644 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001645 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1646 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1647 " does "
1648 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1649 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001650 }
1651 }
1652
Petr Krausb3fcdb42018-01-09 22:09:09 +01001653 // validate the VkViewports
1654 if (!has_dynamic_viewport && viewport_state.pViewports) {
1655 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1656 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001657 const char *fn_name = "vkCreateGraphicsPipelines";
1658 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1659 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1660 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001661 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001662 }
1663 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001664
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001665 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001666 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1667 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1668 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1669 "VK_NV_clip_space_w_scaling extension is not enabled.",
1670 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001671 }
1672
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001673 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001674 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1675 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1676 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1677 "VK_EXT_discard_rectangles extension is not enabled.",
1678 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001679 }
1680
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001681 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001682 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1683 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1684 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1685 "VK_EXT_sample_locations extension is not enabled.",
1686 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001687 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001688
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001689 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001690 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1691 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1692 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1693 "VK_NV_scissor_exclusive extension is not enabled.",
1694 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001695 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001696
1697 if (coarse_sample_order_struct &&
1698 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1699 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001700 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1701 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1702 "] "
1703 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1704 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1705 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001706 }
1707
1708 if (coarse_sample_order_struct) {
1709 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001710 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001711 }
1712 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001713
1714 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1715 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001716 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1717 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1718 "] "
1719 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1720 ") "
1721 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1722 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001723 }
1724 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001725 skip |= LogError(
1726 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001727 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1728 "] "
1729 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1730 i);
1731 }
1732 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001733 }
1734
1735 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001736 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1737 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1738 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1739 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001740 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001741 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1742 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1743 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001744 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001745 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001746 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001747 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001748 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001749 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001750 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001751 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1752 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001753
1754 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001755 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001756 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001757 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001758
1759 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001760 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001761 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1762 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1763
1764 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001765 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001766 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1767 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001768 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001769 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001770
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001771 skip |= validate_flags(
1772 "vkCreateGraphicsPipelines",
1773 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1774 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001775 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001776
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001777 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001778 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001779 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1780 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1781
1782 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001783 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001784 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1785 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1786
1787 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001788 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1789 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
1790 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
1791 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001792 }
John Zulauf7acac592017-11-06 11:15:53 -07001793 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001794 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001795 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
1796 "vkCreateGraphicsPipelines(): parameter "
1797 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
1798 i);
John Zulauf7acac592017-11-06 11:15:53 -07001799 }
1800 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
1801 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
1802 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001803 skip |= LogError(
1804 device,
1805
Dave Houlton413a6782018-05-22 13:01:54 -06001806 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001807 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07001808 }
1809 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001810
1811 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
1812 pCreateInfos[i].pRasterizationState->pNext);
1813
1814 if (line_state) {
1815 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
1816 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
1817 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
1818 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001819 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1820 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1821 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
1822 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001823 }
1824 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
1825 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001826 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1827 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1828 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
1829 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001830 }
1831 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
1832 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001833 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
1834 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
1835 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
1836 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001837 }
1838 }
1839 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
1840 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
1841 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001842 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
1843 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
1844 "range [1,256].",
1845 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001846 }
1847 }
1848 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07001849 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001850 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1851 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001852 skip |=
1853 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
1854 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1855 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
1856 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001857 }
1858 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1859 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001860 skip |=
1861 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
1862 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1863 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
1864 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001865 }
1866 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1867 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001868 skip |=
1869 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
1870 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1871 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
1872 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001873 }
1874 if (line_state->stippledLineEnable) {
1875 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
1876 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 skip |=
1878 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
1879 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1880 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
1881 "stippledRectangularLines feature.",
1882 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001883 }
1884 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
1885 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001886 skip |=
1887 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
1888 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1889 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
1890 "stippledBresenhamLines feature.",
1891 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001892 }
1893 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
1894 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001895 skip |=
1896 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
1897 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1898 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
1899 "stippledSmoothLines feature.",
1900 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001901 }
1902 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
1903 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001904 skip |=
1905 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
1906 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
1907 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
1908 "stippledRectangularLines and strictLines features.",
1909 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001910 }
1911 }
1912 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001913 }
1914
Petr Krause91f7a12017-12-14 20:57:36 +01001915 bool uses_color_attachment = false;
1916 bool uses_depthstencil_attachment = false;
1917 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001918 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001919 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
1920 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01001921 const auto &subpasses_uses = subpasses_uses_it->second;
1922 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
1923 uses_color_attachment = true;
1924 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
1925 uses_depthstencil_attachment = true;
1926 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07001927 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01001928 }
1929
1930 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001931 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001932 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001933 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001934 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001935 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001936
1937 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001938 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001939 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001940 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001941
1942 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001943 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001944 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
1945 pCreateInfos[i].pDepthStencilState->depthTestEnable);
1946
1947 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001948 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001949 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
1950 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
1951
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].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
1955 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001956 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001957
1958 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001959 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001960 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
1961 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
1962
1963 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001964 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001965 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
1966 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
1967
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].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
1971 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001972 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001973
1974 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001975 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001976 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
1977 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001978 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979
1980 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001981 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001982 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
1983 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001984 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001985
1986 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001987 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
1989 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001990 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001991
1992 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
1995 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06001996 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001997
1998 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001999 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002000 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2001 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002002 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002003
2004 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002005 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002006 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2007 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002008 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002009
2010 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002011 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2013 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002014 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002015
2016 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002017 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2018 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2019 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2020 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002021 }
2022 }
2023
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002024 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2025 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2026
Petr Krause91f7a12017-12-14 20:57:36 +01002027 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002028 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2029 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2030 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2031 pCreateInfos[i].pColorBlendState,
2032 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2033 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2034
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002035 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002036 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002037 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2038 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2039 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002040 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002041 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2042 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002043
2044 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002045 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002046 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002047 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002048
2049 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002050 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002051 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2052 pCreateInfos[i].pColorBlendState->logicOpEnable);
2053
2054 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002055 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002056 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2057 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002058 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002059 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002060
2061 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2062 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2063 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002064 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2066 ParameterName::IndexVector{i, attachmentIndex}),
2067 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2068
2069 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002070 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002071 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2072 ParameterName::IndexVector{i, attachmentIndex}),
2073 "VkBlendFactor", AllVkBlendFactorEnums,
2074 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002075 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002076
2077 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002078 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002079 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2080 ParameterName::IndexVector{i, attachmentIndex}),
2081 "VkBlendFactor", AllVkBlendFactorEnums,
2082 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002083 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002084
2085 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002086 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002087 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2088 ParameterName::IndexVector{i, attachmentIndex}),
2089 "VkBlendOp", AllVkBlendOpEnums,
2090 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002091 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002092
2093 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002094 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002095 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2096 ParameterName::IndexVector{i, attachmentIndex}),
2097 "VkBlendFactor", AllVkBlendFactorEnums,
2098 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002099 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002100
2101 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002102 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002103 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2104 ParameterName::IndexVector{i, attachmentIndex}),
2105 "VkBlendFactor", AllVkBlendFactorEnums,
2106 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002107 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002108
2109 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002110 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002111 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2112 ParameterName::IndexVector{i, attachmentIndex}),
2113 "VkBlendOp", AllVkBlendOpEnums,
2114 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002115 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002116
2117 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002118 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002119 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2120 ParameterName::IndexVector{i, attachmentIndex}),
2121 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2122 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002123 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002124 }
2125 }
2126
2127 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002128 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2129 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2130 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2131 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002132 }
2133
2134 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2135 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2136 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002137 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002138 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002139 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2140 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 }
2142 }
2143 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002144
Petr Kraus9752aae2017-11-24 03:05:50 +01002145 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2146 if (pCreateInfos[i].basePipelineIndex != -1) {
2147 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002148 skip |=
2149 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2150 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2151 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2152 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002153 }
2154 }
2155
Petr Kraus9752aae2017-11-24 03:05:50 +01002156 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2157 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002158 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2159 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2160 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2161 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002163 } else {
2164 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002165 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2166 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2167 "index into the pCreateInfos array, of size %d.",
2168 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002169 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 }
2171 }
2172
Petr Kraus9752aae2017-11-24 03:05:50 +01002173 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002174 if (!device_extensions.vk_nv_fill_rectangle) {
2175 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2176 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002177 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2178 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2179 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2180 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002181 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2182 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002183 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2184 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2185 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2186 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002187 }
2188 } else {
2189 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2190 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2191 (physical_device_features.fillModeNonSolid == false)) {
2192 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002193 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2194 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2195 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2196 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002197 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198 }
Petr Kraus299ba622017-11-24 03:09:03 +01002199
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002200 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002201 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002202 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2203 "The line width state is static (pCreateInfos[%" PRIu32
2204 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2205 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2206 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2207 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002208 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002209 }
2210
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211 for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002212 skip |= validate_string("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, j}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002214 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[j].pName);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002215 }
2216 }
2217 }
2218
2219 return skip;
2220}
2221
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002222bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2223 uint32_t createInfoCount,
2224 const VkComputePipelineCreateInfo *pCreateInfos,
2225 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002226 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002227 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002228 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002229 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002230 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002231 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002232 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2233 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 skip |=
2235 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2236 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2237 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2238 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002239 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002240
2241 // Make sure compute stage is selected
2242 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2244 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2245 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002246 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002247 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002248 return skip;
2249}
2250
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002251bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002252 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254
2255 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002256 const auto &features = physical_device_features;
2257 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002258
John Zulauf71968502017-10-26 13:51:15 -06002259 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2260 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2262 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2263 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2264 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002265 }
2266
2267 // Anistropy cannot be enabled in sampler unless enabled as a feature
2268 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002269 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2270 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2271 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002272 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002273 }
John Zulauf71968502017-10-26 13:51:15 -06002274
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002275 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2276 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002277 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2278 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2279 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2280 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002281 }
2282 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002283 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2284 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2285 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2286 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002287 }
2288 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002289 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2290 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2291 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2292 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002293 }
2294 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2295 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2296 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2297 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002298 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2299 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2300 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2301 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2302 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2303 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002304 }
2305 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002306 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2307 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2308 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002309 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002310 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002311 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2312 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2313 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002314 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315 }
2316
2317 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2318 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002319 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2320 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321 }
2322
2323 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2324 // valid VkBorderColor value
2325 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2326 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2327 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002328 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2329 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002330 }
2331
2332 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2333 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002334 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002335 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2336 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2337 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002338 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002339 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2340 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2341 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
John Zulauf275805c2017-10-26 15:34:49 -06002343
2344 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002345 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002346 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2347 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002348 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2349 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2350 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002351 }
2352 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002353
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002354 // Check for valid Lod range
2355 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002356 skip |=
2357 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2358 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002359 }
2360
2361 // Check mipLodBias to device limit
2362 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002363 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2364 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2365 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002366 }
2367
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002368 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2369 if (sampler_conversion != nullptr) {
2370 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2371 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2372 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2373 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002375 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002376 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2377 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2378 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2379 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2380 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2381 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2382 }
2383 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002384 }
2385
2386 return skip;
2387}
2388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002389bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2390 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2391 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002392 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002393 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002394
2395 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2396 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2397 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2398 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
2399 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount
2400 // is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a pointer to an array of descriptorCount
2401 // valid VkSampler handles
2402 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2403 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2404 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2405 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2406 ++descriptor_index) {
2407 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002408 skip |= LogError(device, kVUID_PVError_RequiredParameter,
2409 "vkCreateDescriptorSetLayout: required parameter "
2410 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2411 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002412 }
2413 }
2414 }
2415
2416 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2417 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2418 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2420 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2421 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2422 "values.",
2423 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002424 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002425
2426 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2427 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2428 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2429 skip |=
2430 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2431 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2432 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2433 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2434 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2435 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
2437 }
2438 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002439 return skip;
2440}
2441
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002442bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2443 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002444 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2446 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2447 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002448 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2449 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450}
2451
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002452bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2453 const VkWriteDescriptorSet *pDescriptorWrites,
2454 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002455 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002456
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002457 if (pDescriptorWrites != NULL) {
2458 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2459 // descriptorCount must be greater than 0
2460 if (pDescriptorWrites[i].descriptorCount == 0) {
2461 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002462 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2463 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 }
2465
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002466 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2467 if (validateDstSet) {
2468 // dstSet must be a valid VkDescriptorSet handle
2469 skip |= validate_required_handle(vkCallingFunction,
2470 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2471 pDescriptorWrites[i].dstSet);
2472 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473
2474 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2475 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2476 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2477 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2478 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2479 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2480 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
2481 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures
2482 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002483 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2484 "%s(): if pDescriptorWrites[%d].descriptorType is "
2485 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2486 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2487 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2488 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002489 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2490 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2491 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageView and imageLayout
2492 // members of any given element of pImageInfo must be a valid VkImageView and VkImageLayout, respectively
2493 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2494 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002495 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002496 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageView",
2497 ParameterName::IndexVector{i, descriptor_index}),
2498 pDescriptorWrites[i].pImageInfo[descriptor_index].imageView);
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002499 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2501 ParameterName::IndexVector{i, descriptor_index}),
2502 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002503 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002504 }
2505 }
2506 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2507 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2508 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2509 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2510 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2511 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2512 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
2513 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2515 "%s(): if pDescriptorWrites[%d].descriptorType is "
2516 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2517 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2518 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2519 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520 } else {
2521 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount; ++descriptorIndex) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002522 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002523 ParameterName("pDescriptorWrites[%i].pBufferInfo[%i].buffer",
2524 ParameterName::IndexVector{i, descriptorIndex}),
2525 pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer);
2526 }
2527 }
2528 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2529 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
2530 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
2531 // pTexelBufferView must be a pointer to an array of descriptorCount valid VkBufferView handles
2532 if (pDescriptorWrites[i].pTexelBufferView == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002533 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00323",
2534 "%s(): if pDescriptorWrites[%d].descriptorType is "
2535 "VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, "
2536 "pDescriptorWrites[%d].pTexelBufferView must not be NULL.",
2537 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538 } else {
2539 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2540 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002541 skip |= validate_required_handle(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002542 ParameterName("pDescriptorWrites[%i].pTexelBufferView[%i]",
2543 ParameterName::IndexVector{i, descriptor_index}),
2544 pDescriptorWrites[i].pTexelBufferView[descriptor_index]);
2545 }
2546 }
2547 }
2548
2549 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2550 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002551 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2553 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2554 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002555 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002556 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2557 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2558 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2559 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002560 }
2561 }
2562 }
2563 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2564 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002565 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2567 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2568 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002569 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002570 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2571 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2572 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2573 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002574 }
2575 }
2576 }
2577 }
2578 }
2579 }
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002580
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 return skip;
2582}
2583
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002584bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2585 const VkWriteDescriptorSet *pDescriptorWrites,
2586 uint32_t descriptorCopyCount,
2587 const VkCopyDescriptorSet *pDescriptorCopies) const {
2588 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2589}
2590
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002591bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002592 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002593 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002594 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2595}
2596
2597bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002598 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002599 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002600 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2601}
2602
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002603bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2604 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002605 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607
2608 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2609 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2610 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002611 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2612 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002613 return skip;
2614}
2615
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002616bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002617 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002619
2620 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2621 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2623
Petr Krause7bb9e82019-08-11 21:34:43 +02002624 // Implicit VUs
2625 // validate only sType here; pointer has to be validated in core_validation
2626 const bool kNotRequired = false;
2627 const char *kNoVUID = nullptr;
2628 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2629 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2630 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631
Petr Krause7bb9e82019-08-11 21:34:43 +02002632 if (pInfo) {
2633 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2634 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2635 skip |= validate_struct_pnext(
2636 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2637 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002638 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2639 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002640
Petr Krause7bb9e82019-08-11 21:34:43 +02002641 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642
Petr Krause7bb9e82019-08-11 21:34:43 +02002643 // Explicit VUs
2644 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002645 skip |= LogError(
2646 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002647 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2648 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002649 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002650
2651 if (physical_device_features.inheritedQueries) {
2652 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002653 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002654 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002655 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002656 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002657 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002658 }
2659
2660 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002661 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002662 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002663 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002664 } else { // !pipelineStatisticsQuery
2665 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2666 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 }
Petr Kraus139757b2019-08-15 17:19:33 +02002668
2669 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2670 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002671 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002672 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2673 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002674 skip |= LogError(
2675 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002676 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2677 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2678 }
2679 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002680 }
2681
2682 return skip;
2683}
2684
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002685bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002686 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002688
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002689 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01002690 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002691 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
2692 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
2693 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01002694 }
2695 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002696 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
2697 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
2698 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01002699 }
2700 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01002701 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002702 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002703 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
2704 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2705 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2706 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 }
2708 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01002709
2710 if (pViewports) {
2711 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
2712 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002713 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002714 skip |= manual_PreCallValidateViewport(
2715 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01002716 }
2717 }
2718
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002719 return skip;
2720}
2721
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002722bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002723 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002726 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002728 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
2729 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
2730 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002731 }
2732 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002733 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
2734 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
2735 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002736 }
2737 } else { // multiViewport enabled
2738 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002739 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002740 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
2741 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
2742 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2743 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 }
2745 }
2746
Petr Kraus6260f0a2018-02-27 21:15:55 +01002747 if (pScissors) {
2748 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
2749 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002750
Petr Kraus6260f0a2018-02-27 21:15:55 +01002751 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2753 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
2754 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002755 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756
Petr Kraus6260f0a2018-02-27 21:15:55 +01002757 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002758 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
2759 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
2760 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002761 }
2762
2763 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
2764 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002765 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
2766 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2767 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2768 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002769 }
2770
2771 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
2772 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
2774 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
2775 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
2776 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01002777 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002778 }
2779 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01002780
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002781 return skip;
2782}
2783
Jeff Bolz5c801d12019-10-09 10:38:45 -05002784bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01002785 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01002786
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002787 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002788 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
2789 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002790 }
2791
2792 return skip;
2793}
2794
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002795bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002796 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002798 if (vertexCount == 0) {
2799 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
2800 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803
2804 if (instanceCount == 0) {
2805 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
2806 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002808 }
2809 return skip;
2810}
2811
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002812bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002813 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002816 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002817 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2818 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 }
2820 return skip;
2821}
2822
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002823bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002824 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002826 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |=
2828 LogError(device, kVUID_PVError_DeviceFeature,
2829 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 }
2831 return skip;
2832}
2833
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002834bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
2835 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002836 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002837 bool skip = false;
2838 for (uint32_t rect = 0; rect < rectCount; rect++) {
2839 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002840 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
2841 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06002842 }
2843 }
2844 return skip;
2845}
2846
Andrew Fobel3abeb992020-01-20 16:33:22 -05002847bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
2848 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2849 VkImageFormatProperties2 *pImageFormatProperties,
2850 const char *apiName) const {
2851 bool skip = false;
2852
2853 if (pImageFormatInfo != nullptr) {
2854 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
2855 if (image_stencil_struct != nullptr) {
2856 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
2857 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
2858 // No flags other than the legal attachment bits may be set
2859 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
2860 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002861 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
2862 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
2863 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
2864 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
2865 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05002866 }
2867 }
2868 }
2869 }
2870
2871 return skip;
2872}
2873
2874bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
2875 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2876 VkImageFormatProperties2 *pImageFormatProperties) const {
2877 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2878 "vkGetPhysicalDeviceImageFormatProperties2");
2879}
2880
2881bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
2882 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
2883 VkImageFormatProperties2 *pImageFormatProperties) const {
2884 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
2885 "vkGetPhysicalDeviceImageFormatProperties2KHR");
2886}
2887
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002888bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2889 VkImageLayout srcImageLayout, VkImage dstImage,
2890 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002891 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893
Dave Houltonf5217612018-02-02 16:18:52 -07002894 VkImageAspectFlags legal_aspect_flags =
2895 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 -07002896 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002897 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2898 }
2899
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002901 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002902 skip |= LogError(
2903 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002904 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002905 }
Dave Houltonf5217612018-02-02 16:18:52 -07002906 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002907 skip |= LogError(
2908 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002909 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910 }
2911 }
2912 return skip;
2913}
2914
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002915bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
2916 VkImageLayout srcImageLayout, VkImage dstImage,
2917 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002918 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920
Dave Houltonf5217612018-02-02 16:18:52 -07002921 VkImageAspectFlags legal_aspect_flags =
2922 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 -07002923 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002924 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2925 }
2926
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002927 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002928 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002929 skip |= LogError(
2930 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
2932 }
Dave Houltonf5217612018-02-02 16:18:52 -07002933 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002934 skip |= LogError(
2935 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
2937 }
2938 }
2939 return skip;
2940}
2941
sfricke-samsung3999ef62020-02-09 17:05:59 -08002942bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
2943 uint32_t regionCount, const VkBufferCopy *pRegions) const {
2944 bool skip = false;
2945
2946 if (pRegions != nullptr) {
2947 for (uint32_t i = 0; i < regionCount; i++) {
2948 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002949 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
2950 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08002951 }
2952 }
2953 }
2954 return skip;
2955}
2956
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002957bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
2958 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002959 uint32_t regionCount,
2960 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962
Dave Houltonf5217612018-02-02 16:18:52 -07002963 VkImageAspectFlags legal_aspect_flags =
2964 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 -07002965 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002966 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2967 }
2968
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002969 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002970 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002971 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
2972 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
2973 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002974 }
2975 }
2976 return skip;
2977}
2978
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002979bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
2980 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002981 uint32_t regionCount,
2982 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002984
Dave Houltonf5217612018-02-02 16:18:52 -07002985 VkImageAspectFlags legal_aspect_flags =
2986 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 -07002987 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07002988 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
2989 }
2990
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07002992 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002993 LogError(device, kVUID_PVError_UnrecognizedValue,
2994 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
2995 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002996 }
2997 }
2998 return skip;
2999}
3000
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003001bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003002 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3003 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005
3006 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003007 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3008 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3009 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 }
3011
3012 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003013 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3014 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3015 "), must be greater than zero and less than or equal to 65536.",
3016 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003017 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003018 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3019 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3020 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 }
3022 return skip;
3023}
3024
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003025bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003026 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028
3029 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003030 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3031 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3032 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003033 }
3034
3035 if (size != VK_WHOLE_SIZE) {
3036 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003037 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003038 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3039 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003040 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003041 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3042 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043 }
3044 }
3045 return skip;
3046}
3047
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003048bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003049 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003050 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003052
3053 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003054 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3055 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3056 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3057 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3059 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3060 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003061 }
3062
3063 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3064 // queueFamilyIndexCount uint32_t values
3065 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003066 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3067 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3068 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3069 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003070 }
3071 }
3072
Dave Houlton413a6782018-05-22 13:01:54 -06003073 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003075 }
3076
3077 return skip;
3078}
3079
Jeff Bolz5c801d12019-10-09 10:38:45 -05003080bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003081 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082
3083 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003084 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3085 if (present_regions) {
3086 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003087 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003088 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3089 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003090 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3091 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3092 "extension swapchainCount is %i. These values must be equal.",
3093 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003094 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003095 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003096 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3097 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003098 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3099 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3100 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003101 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003102 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003103 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003104 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003106 }
3107 }
3108
3109 return skip;
3110}
3111
3112#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003113bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3114 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3115 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003116 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003117 bool skip = false;
3118
3119 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3121 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003122 }
3123
3124 return skip;
3125}
3126#endif // VK_USE_PLATFORM_WIN32_KHR
3127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003128bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003129 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003130 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003131 bool skip = false;
3132
3133 if (pCreateInfo) {
3134 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003135 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3136 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003137 }
3138
3139 if (pCreateInfo->pPoolSizes) {
3140 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3141 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003142 skip |= LogError(
3143 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003144 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003145 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003146 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3147 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003148 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3149 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3150 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3151 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3152 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003153 }
Petr Krausc8655be2017-09-27 18:56:51 +02003154 }
3155 }
3156 }
3157
3158 return skip;
3159}
3160
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003161bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003162 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003163 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003164
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003165 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003166 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003167 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3168 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3169 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003170 }
3171
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003172 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003173 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003174 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3175 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3176 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003177 }
3178
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003179 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003180 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003181 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3182 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3183 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003184 }
3185
3186 return skip;
3187}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003188
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003189bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003190 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003191 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003192
3193 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003194 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3195 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003196 }
3197 return skip;
3198}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003199
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003200bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3201 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003202 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003203 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003204
3205 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003206 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003207 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3209 "vkCmdDispatch(): baseGroupX (%" PRIu32
3210 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3211 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003212 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003213 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3214 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3215 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3216 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003217 }
3218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003219 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003220 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3222 "vkCmdDispatch(): baseGroupY (%" PRIu32
3223 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3224 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003225 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003226 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3227 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3228 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3229 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003230 }
3231
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003232 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003233 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003234 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3235 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3236 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3237 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003238 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003239 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3240 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3241 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3242 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003243 }
3244
3245 return skip;
3246}
3247
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003248bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3249 VkPipelineBindPoint pipelineBindPoint,
3250 VkPipelineLayout layout, uint32_t set,
3251 uint32_t descriptorWriteCount,
3252 const VkWriteDescriptorSet *pDescriptorWrites) const {
3253 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3254}
3255
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003256bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3257 uint32_t firstExclusiveScissor,
3258 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003259 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003260 bool skip = false;
3261
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003262 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003263 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003264 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003265 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3266 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3267 ") is not 0.",
3268 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003269 }
3270 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003271 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003272 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3273 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3274 ") is not 1.",
3275 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003276 }
3277 } else { // multiViewport enabled
3278 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003279 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003280 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3281 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3282 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3283 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003284 }
3285 }
3286
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003287 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003288 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3289 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3290 ") must be less than maxViewports (=%" PRIu32 ").",
3291 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003292 }
3293
3294 if (pExclusiveScissors) {
3295 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3296 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3297
3298 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003299 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3300 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3301 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003302 }
3303
3304 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3306 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3307 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003308 }
3309
3310 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3311 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3313 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3314 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3315 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003316 }
3317
3318 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3319 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003320 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3321 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3322 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3323 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003324 }
3325 }
3326 }
3327
3328 return skip;
3329}
3330
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003331bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3332 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003333 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003334 bool skip = false;
3335 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003336 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3337 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3338 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003339 } else {
3340 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3341 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003342 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3343 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3344 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3345 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003346 }
3347 }
3348
3349 return skip;
3350}
3351
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003352bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3353 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003354 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003355 bool skip = false;
3356
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003357 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003358 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003359 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003360 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3361 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3362 ") is not 0.",
3363 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003364 }
3365 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003366 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003367 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3368 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3369 ") is not 1.",
3370 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003371 }
3372 }
3373
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003374 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003375 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3376 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3377 ") must be less than maxViewports (=%" PRIu32 ").",
3378 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003379 }
3380
3381 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003382 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003383 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3384 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3385 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3386 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003387 }
3388
3389 return skip;
3390}
3391
Jeff Bolz5c801d12019-10-09 10:38:45 -05003392bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3393 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3394 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003395 bool skip = false;
3396
Dave Houlton142c4cb2018-10-17 15:04:41 -06003397 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003398 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3399 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3400 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003401 }
3402
3403 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003404 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003405 }
3406
3407 return skip;
3408}
3409
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003410bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003411 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003412 bool skip = false;
3413
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003414 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003415 skip |= LogError(
3416 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003417 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3418 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003419 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003420 }
3421
3422 return skip;
3423}
3424
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003425bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3426 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003427 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003428 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003429 static const int condition_multiples = 0b0011;
3430 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003431 skip |= LogError(
3432 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003433 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003434 }
Lockee1c22882019-06-10 16:02:54 -06003435 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003436 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3437 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3438 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3439 stride);
Lockee1c22882019-06-10 16:02:54 -06003440 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003441 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(
3443 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3444 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003445 }
3446
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003447 return skip;
3448}
3449
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003450bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3451 VkDeviceSize offset, VkBuffer countBuffer,
3452 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003453 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003454 bool skip = false;
3455
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003456 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003457 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3458 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3459 "), is not a multiple of 4.",
3460 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003461 }
3462
3463 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3465 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3466 "), is not a multiple of 4.",
3467 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003468 }
3469
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003470 return skip;
3471}
3472
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003473bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003474 const VkAllocationCallbacks *pAllocator,
3475 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003476 bool skip = false;
3477
3478 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3479 if (pCreateInfo != nullptr) {
3480 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3481 // VkQueryPipelineStatisticFlagBits values
3482 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3483 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3485 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3486 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3487 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003488 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003489 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003490 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491}
3492
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003493bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3494 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003495 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003496 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3497 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003498}
3499
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003500void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003501 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3502 VkResult result) {
3503 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003504 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505}
3506
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003507void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003508 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3509 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003510 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003511 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003512 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003513}
3514
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003515void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3516 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003517 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003518 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003519 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003520}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003521
3522bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003523 const VkAllocationCallbacks *pAllocator,
3524 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003525 bool skip = false;
3526
3527 if (pAllocateInfo) {
3528 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3529 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003530 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3531 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003532 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003533
3534 VkMemoryAllocateFlags flags = 0;
3535 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3536 if (flags_info) {
3537 flags = flags_info->flags;
3538 }
3539
3540 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3541 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3542 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003543 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3544 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3545 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003546 }
3547
3548#ifdef VK_USE_PLATFORM_WIN32_KHR
3549 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3550#endif
3551 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3552 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3553#ifdef VK_USE_PLATFORM_ANDROID_KHR
3554 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3555#endif
3556
3557 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003558 skip |= LogError(
3559 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003560 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3561 }
3562 if (
3563#ifdef VK_USE_PLATFORM_WIN32_KHR
3564 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3565#endif
3566 (import_memory_fd && import_memory_fd->handleType) ||
3567#ifdef VK_USE_PLATFORM_ANDROID_KHR
3568 (import_memory_ahb && import_memory_ahb->buffer) ||
3569#endif
3570 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003571 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3572 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003573 }
3574 }
3575
3576 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003577 VkBool32 capture_replay = false;
3578 VkBool32 buffer_device_address = false;
3579 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3580 if (vulkan_12_features) {
3581 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3582 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3583 } else {
3584 const auto *bda_features =
3585 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3586 if (bda_features) {
3587 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3588 buffer_device_address = bda_features->bufferDeviceAddress;
3589 }
3590 }
3591 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003592 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3593 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3594 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003595 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003596 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3598 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003599 }
3600 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003601 }
3602 return skip;
3603}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003604
Jason Macnak192fa0e2019-07-26 15:07:16 -07003605bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003606 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003607 bool skip = false;
3608
3609 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3610 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3611 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003612 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003613 } else {
3614 uint32_t vertex_component_size = 0;
3615 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
3616 vertex_component_size = 4;
3617 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
3618 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
3619 vertex_component_size = 2;
3620 }
3621 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003622 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003623 }
3624 }
3625
3626 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
3627 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003629 } else {
3630 uint32_t index_element_size = 0;
3631 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
3632 index_element_size = 4;
3633 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
3634 index_element_size = 2;
3635 }
3636 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003637 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003638 }
3639 }
3640 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
3641 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003642 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003643 }
3644 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003646 }
3647 }
3648
3649 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003651 }
3652
3653 return skip;
3654}
3655
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003656bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
3657 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003658 bool skip = false;
3659
3660 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003661 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003662 }
3663 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003664 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003665 }
3666
3667 return skip;
3668}
3669
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
3671 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003672 bool skip = false;
3673 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003674 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003675 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003676 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003677 }
3678 return skip;
3679}
3680
3681bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003682 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07003683 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003684 bool skip = false;
3685 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003686 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
3687 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
3688 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003689 }
3690 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003691 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
3692 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
3693 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07003694 }
3695 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
3696 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003697 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
3698 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
3699 "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 -07003700 }
3701 if (info.geometryCount > phys_dev_ext_props.ray_tracing_props.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003702 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
3703 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
3704 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003705 }
3706 if (info.instanceCount > phys_dev_ext_props.ray_tracing_props.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003707 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
3708 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
3709 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003710 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003711 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07003712 uint64_t total_triangle_count = 0;
3713 for (uint32_t i = 0; i < info.geometryCount; i++) {
3714 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07003715
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07003717
Jason Macnak5c954952019-07-09 15:46:12 -07003718 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
3719 continue;
3720 }
3721 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
3722 }
3723 if (total_triangle_count > phys_dev_ext_props.ray_tracing_props.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003724 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
3725 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
3726 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07003727 }
3728 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07003729 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
3730 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
3731 for (uint32_t i = 1; i < info.geometryCount; i++) {
3732 const VkGeometryNV &geometry = info.pGeometries[i];
3733 if (geometry.geometryType != first_geometry_type) {
3734 // TODO: update fake VUID below with the real one once it is generated.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003735 skip |= LogError(device, "UNASSIGNED-VkAccelerationStructureInfoNV-pGeometries-XXXX",
3736 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
3737 "info.pGeometries[0].geometryType.",
3738 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07003739 }
3740 }
3741 }
Jason Macnak5c954952019-07-09 15:46:12 -07003742 return skip;
3743}
3744
Ricardo Garciaa4935972019-02-21 17:43:18 +01003745bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
3746 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003747 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01003748 bool skip = false;
3749
3750 if (pCreateInfo) {
3751 if ((pCreateInfo->compactedSize != 0) &&
3752 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003753 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
3754 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
3755 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
3756 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01003757 }
Jason Macnak5c954952019-07-09 15:46:12 -07003758
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003759 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07003760 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01003761 }
3762
3763 return skip;
3764}
Mike Schuchardt21638df2019-03-16 10:52:02 -07003765
Jeff Bolz5c801d12019-10-09 10:38:45 -05003766bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
3767 const VkAccelerationStructureInfoNV *pInfo,
3768 VkBuffer instanceData, VkDeviceSize instanceOffset,
3769 VkBool32 update, VkAccelerationStructureNV dst,
3770 VkAccelerationStructureNV src, VkBuffer scratch,
3771 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003772 bool skip = false;
3773
3774 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003775 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07003776 }
3777
3778 return skip;
3779}
3780
3781bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
3782 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003783 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07003784 bool skip = false;
3785 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003786 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
3787 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07003788 }
3789 return skip;
3790}
3791
Peter Chen85366392019-05-14 15:20:11 -04003792bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
3793 uint32_t createInfoCount,
3794 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
3795 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003796 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04003797 bool skip = false;
3798
3799 for (uint32_t i = 0; i < createInfoCount; i++) {
3800 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
3801 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003802 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
3803 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
3804 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
3805 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
3806 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04003807 }
3808 }
3809
3810 return skip;
3811}
3812
Mike Schuchardt21638df2019-03-16 10:52:02 -07003813#ifdef VK_USE_PLATFORM_WIN32_KHR
3814bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
3815 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003816 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07003817 bool skip = false;
3818 if (!device_extensions.vk_khr_swapchain)
3819 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
3820 if (!device_extensions.vk_khr_get_surface_capabilities_2)
3821 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
3822 if (!device_extensions.vk_khr_surface)
3823 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
3824 if (!device_extensions.vk_khr_get_physical_device_properties_2)
3825 skip |=
3826 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
3827 if (!device_extensions.vk_ext_full_screen_exclusive)
3828 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
3829 skip |= validate_struct_type(
3830 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
3831 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
3832 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
3833 if (pSurfaceInfo != NULL) {
3834 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
3835 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
3836 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
3837
3838 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
3839 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
3840 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
3841 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08003842 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
3843 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07003844
3845 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
3846 }
3847 return skip;
3848}
3849#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01003850
3851bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
3852 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003853 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01003854 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3855 bool skip = false;
3856 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
3857 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
3858 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
3859 }
3860 return skip;
3861}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003862
3863bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003864 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003865 bool skip = false;
3866
3867 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003868 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
3869 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05003870 }
3871
3872 return skip;
3873}
Piers Daniell8fd03f52019-08-21 12:07:53 -06003874
3875bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003876 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06003877 bool skip = false;
3878
3879 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003880 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
3881 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003882 }
3883
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003884 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Piers Daniell8fd03f52019-08-21 12:07:53 -06003885 if (indexType == VK_INDEX_TYPE_UINT8_EXT && !index_type_uint8_features->indexTypeUint8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003886 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
3887 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06003888 }
3889
3890 return skip;
3891}
Mark Lobodzinski84988402019-09-11 15:27:30 -06003892
sfricke-samsung4ada8d42020-02-09 17:43:11 -08003893bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
3894 uint32_t bindingCount, const VkBuffer *pBuffers,
3895 const VkDeviceSize *pOffsets) const {
3896 bool skip = false;
3897 if (firstBinding > device_limits.maxVertexInputBindings) {
3898 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
3899 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
3900 device_limits.maxVertexInputBindings);
3901 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
3902 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
3903 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
3904 "maxVertexInputBindings (%u)",
3905 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
3906 }
3907
3908 return skip;
3909}
3910
Mark Lobodzinski84988402019-09-11 15:27:30 -06003911bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003912 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003913 bool skip = false;
3914 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
3916 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003917 }
3918 return skip;
3919}
3920
3921bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003922 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06003923 bool skip = false;
3924 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003925 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
3926 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06003927 }
3928 return skip;
3929}
Petr Kraus3d720392019-11-13 02:52:39 +01003930
3931bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
3932 VkSemaphore semaphore, VkFence fence,
3933 uint32_t *pImageIndex) const {
3934 bool skip = false;
3935
3936 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003937 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
3938 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003939 }
3940
3941 return skip;
3942}
3943
3944bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
3945 uint32_t *pImageIndex) const {
3946 bool skip = false;
3947
3948 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003949 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
3950 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01003951 }
3952
3953 return skip;
3954}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003955
3956bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
3957 uint32_t firstInstance, VkBuffer counterBuffer,
3958 VkDeviceSize counterBufferOffset,
3959 uint32_t counterOffset, uint32_t vertexStride) const {
3960 bool skip = false;
3961
3962 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003963 skip |= LogError(
3964 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07003965 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
3966 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
3967 }
3968
3969 return skip;
3970}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003971
3972bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
3973 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3974 const VkAllocationCallbacks *pAllocator,
3975 VkSamplerYcbcrConversion *pYcbcrConversion,
3976 const char *apiName) const {
3977 bool skip = false;
3978
3979 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003980 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003981 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003982 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
3983 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08003984 }
3985 return skip;
3986}
3987
3988bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
3989 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
3990 const VkAllocationCallbacks *pAllocator,
3991 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3992 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
3993 "vkCreateSamplerYcbcrConversion");
3994}
3995
3996bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
3997 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
3998 VkSamplerYcbcrConversion *pYcbcrConversion) const {
3999 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4000 "vkCreateSamplerYcbcrConversionKHR");
4001}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004002
4003bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4004 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4005 bool skip = false;
4006 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4007 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4008
4009 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004010 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4011 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4012 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4013 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4014 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004015 }
4016 return skip;
4017}