blob: ab1e12d87c1c80e1ac73a994f41f87dea9f7f46a [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
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
300
Locke77fad1c2019-04-16 13:09:03 -0600301 auto vertex_attribute_divisor_features =
302 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
303 if (vertex_attribute_divisor_features) {
304 bool extension_found = false;
305 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
306 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
307 VK_MAX_EXTENSION_NAME_SIZE)) {
308 extension_found = true;
309 break;
310 }
311 }
312 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700313 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
314 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
315 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600316 }
317 }
318
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
320 if (vulkan_11_features) {
321 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
322 while (current) {
323 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
324 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
325 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
326 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
327 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
328 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700329 skip |= LogError(
330 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700331 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
332 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
333 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
334 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
335 break;
336 }
337 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
338 }
339 }
340
341 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
342 if (vulkan_12_features) {
343 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
344 while (current) {
345 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
346 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
347 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
348 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
349 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
350 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
351 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700358 skip |= LogError(
359 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700360 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
361 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
362 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
363 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
364 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
365 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
366 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
367 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
368 break;
369 }
370 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
371 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700372 // Check features are enabled if matching extension is passed in as well
373 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
374 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
375 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
376 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
377 skip |= LogError(
378 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
379 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
380 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
381 }
382 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
383 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
384 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
386 "is not VK_TRUE.",
387 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
388 }
389 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
390 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
391 skip |= LogError(
392 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
393 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
394 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
395 }
396 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
397 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
398 skip |= LogError(
399 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
400 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
401 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
402 }
403 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
404 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
405 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
406 skip |=
407 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
408 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
409 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
410 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
411 }
412 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700413 }
414
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600415 // Validate pCreateInfo->pQueueCreateInfos
416 if (pCreateInfo->pQueueCreateInfos) {
417 std::unordered_set<uint32_t> set;
418
419 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700420 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
421 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600422 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700423 skip |=
424 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
425 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
426 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
427 "index value.",
428 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600429 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
432 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
433 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 } else {
435 set.insert(requested_queue_family);
436 }
437
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700438 if (queue_create_info.pQueuePriorities != nullptr) {
439 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
440 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600441 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700442 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
443 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
444 "] (=%f) is not between 0 and 1 (inclusive).",
445 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600446 }
447 }
448 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700449
450 // Need to know if protectedMemory feature is passed in preCall to creating the device
451 VkBool32 protectedMemory = VK_FALSE;
452 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
453 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
454 if (protected_features) {
455 protectedMemory = protected_features->protectedMemory;
456 } else if (vulkan_11_features) {
457 protectedMemory = vulkan_11_features->protectedMemory;
458 }
459 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
460 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
461 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
462 "protectedMemory feature being set as well.");
463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600464 }
465 }
466
sfricke-samsung30a57412020-05-15 21:14:54 -0700467 // feature dependencies for VK_KHR_variable_pointers
468 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
469 VkBool32 variablePointers = VK_FALSE;
470 VkBool32 variablePointersStorageBuffer = VK_FALSE;
471 if (vulkan_11_features) {
472 variablePointers = vulkan_11_features->variablePointers;
473 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
474 } else if (variable_pointers_features) {
475 variablePointers = variable_pointers_features->variablePointers;
476 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
477 }
478 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
479 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
480 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
481 }
482
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600483 return skip;
484}
485
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500486bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700487 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700488 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
489 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
490 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600491 }
492
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700493 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600494}
495
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700496bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500497 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100498 bool skip = false;
499
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700501 skip |=
502 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600503
504 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
505 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
506 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
507 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700508 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
509 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
510 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600511 }
512
513 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
514 // queueFamilyIndexCount uint32_t values
515 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700516 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
517 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
518 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
519 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521 }
522
523 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
524 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
525 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
526 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700527 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
528 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
529 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600530 }
531 }
532
533 return skip;
534}
535
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700536bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500537 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600538 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600539
540 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
542 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
543 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
544 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
546 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600548 }
549
550 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
551 // queueFamilyIndexCount uint32_t values
552 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700553 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
554 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
555 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
556 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600557 }
558 }
559
Dave Houlton413a6782018-05-22 13:01:54 -0600560 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700561 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600562 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700563 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600564 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700565 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566
Dave Houlton413a6782018-05-22 13:01:54 -0600567 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700568 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600569 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700570 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600571
Dave Houlton130c0212018-01-29 13:39:56 -0700572 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700573 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
574 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700575 skip |= LogError(
576 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600577 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
578 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700579 }
580
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600581 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100582 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
583 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700584 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
585 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
586 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600587 }
588
589 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100590 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
591 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
593 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
594 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
595 ") are not equal.",
596 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100597 }
598
599 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
601 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
602 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
603 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100604 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 }
606
607 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700608 skip |= LogError(
609 device, "VUID-VkImageCreateInfo-imageType-00957",
610 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 }
612 }
613
Dave Houlton130c0212018-01-29 13:39:56 -0700614 // 3D image may have only 1 layer
615 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700616 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
617 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700618 }
619
620 // If multi-sample, validate type, usage, tiling and mip levels.
621 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
622 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600623 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
625 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700626 }
627
628 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
629 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
630 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
631 // At least one of the legal attachment bits must be set
632 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700633 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
634 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700635 }
636 // No flags other than the legal attachment bits may be set
637 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
638 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700639 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
640 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700641 }
642 }
643
Jeff Bolzef40fec2018-09-01 22:04:34 -0500644 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600645 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500646 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600647 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
648 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500649 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600650 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
652 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
653 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600656 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700657 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
658 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
659 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600660 }
661
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700662 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700663 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
664 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
665 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100666 }
667
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600668 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
669 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
670 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
671 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700672 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
673 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
674 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600675 }
676
677 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
678 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
679 // Linear tiling is unsupported
680 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700681 skip |= LogError(device, kVUID_PVError_InvalidUsage,
682 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
683 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600684 }
685
686 // Sparse 1D image isn't valid
687 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700688 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
689 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600690 }
691
692 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700693 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
695 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
696 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697 }
698
699 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700700 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
702 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
703 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // Multi-sample 2D image when device doesn't support it
707 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700708 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600709 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
711 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
712 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700713 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700715 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
716 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
717 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700718 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
721 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
722 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700723 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600724 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700725 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
726 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
727 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600728 }
729 }
730 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500731
Jeff Bolz9af91c52018-09-01 21:53:57 -0500732 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
733 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700734 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
735 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
736 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500737 }
738 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
740 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
741 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500742 }
743 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
745 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
746 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500747 }
748 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500749
750 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600751 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700752 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
753 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
754 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500755 }
756
Dave Houlton142c4cb2018-10-17 15:04:41 -0600757 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
759 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
760 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
761 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500762 }
763
Dave Houlton142c4cb2018-10-17 15:04:41 -0600764 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700765 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
766 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
767 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
768 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500769 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600770 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700771 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
772 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
773 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
774 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500775 }
776 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500777
sfricke-samsung8f658d42020-05-03 20:12:24 -0700778 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
779 (FormatHasDepth(pCreateInfo->format) == false)) {
780 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
781 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
782 "format must be a depth or depth/stencil format.");
783 }
784
Andrew Fobel3abeb992020-01-20 16:33:22 -0500785 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
786 if (image_stencil_struct != nullptr) {
787 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
788 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
789 // No flags other than the legal attachment bits may be set
790 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
791 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
793 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
794 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
795 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500796 }
797 }
798
799 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
800 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
801 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
802 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700803 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
804 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
805 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
806 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500807 }
808
809 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
810 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700811 LogError(device, "VUID-VkImageCreateInfo-format-02537",
812 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
813 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
814 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500815 }
816 }
817
818 if (!physical_device_features.shaderStorageImageMultisample &&
819 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
820 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
821 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700822 LogError(device, "VUID-VkImageCreateInfo-format-02538",
823 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
824 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
825 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500826 }
827
828 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
829 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700830 skip |= LogError(
831 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500832 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
833 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
834 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
835 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
836 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700837 skip |= LogError(
838 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500839 "vkCreateImage(): Depth-stencil image in which usage does not include "
840 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
841 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
842 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
843 }
844
845 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
846 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 skip |= LogError(
848 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500849 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
850 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
851 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
852 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
853 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700854 skip |= LogError(
855 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500856 "vkCreateImage(): Depth-stencil image in which usage does not include "
857 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
858 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
859 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
860 }
861 }
862 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700863
864 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
865 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
866 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
867 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
868 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
869 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700870
871 if (device_extensions.vk_ext_image_drm_format_modifier) {
872 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
873 const auto drm_format_mod_explict =
874 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
875 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
876 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
877 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
878 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
879 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
880 "either VkImageDrmFormatModifierListCreateInfoEXT or "
881 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
882 }
883 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
884 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
885 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
886 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
887 "in the pNext chain");
888 }
889 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200890
891 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
892 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
893 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
894 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
895 "imageType must be VK_IMAGE_TYPE_2D.");
896 }
897 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
898 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
899 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
900 "samples must be VK_SAMPLE_COUNT_1_BIT.");
901 }
902 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
903 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
904 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
905 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
906 }
907 }
908 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
909 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
910 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
911 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
912 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
913 }
914 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
915 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
916 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
917 "imageType must be VK_IMAGE_TYPE_2D.");
918 }
919 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
920 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
921 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
922 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
923 }
924 if (pCreateInfo->mipLevels != 1) {
925 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
926 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
927 pCreateInfo->mipLevels);
928 }
929 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600930 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500931
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600932 return skip;
933}
934
Jeff Bolz99e3f632020-03-24 22:59:22 -0500935bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
936 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
937 bool skip = false;
938
939 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700940 // Validate feature set if using CUBE_ARRAY
941 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
942 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
943 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
944 "enabling the imageCubeArray feature.");
945 }
946
Jeff Bolz99e3f632020-03-24 22:59:22 -0500947 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
948 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
949 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700950 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500951 pCreateInfo->subresourceRange.layerCount);
952 }
953 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700954 skip |= LogError(
955 device, "VUID-VkImageViewCreateInfo-viewType-02961",
956 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
957 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500958 }
959 }
960 }
961 return skip;
962}
963
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600964bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700965 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100966 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100967
968 // Note: for numerical correctness
969 // - float comparisons should expect NaN (comparison always false).
970 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
971
972 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700973 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100974 if (v1_f <= 0.0f) return true;
975
976 float intpart;
977 const float fract = modff(v1_f, &intpart);
978
979 assert(std::numeric_limits<float>::radix == 2);
980 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
981 if (intpart >= u32_max_plus1) return false;
982
983 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
984 if (v1_u32 < v2_u32)
985 return true;
986 else if (v1_u32 == v2_u32 && fract == 0.0f)
987 return true;
988 else
989 return false;
990 };
991
992 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
993 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
994 return (v1_f <= v2_f);
995 };
996
997 // width
998 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700999 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001000
1001 if (!(viewport.width > 0.0f)) {
1002 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001003 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1004 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001005 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1006 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001007 skip |= LogError(object, "VUID-VkViewport-width-01771",
1008 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1009 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001010 } 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 -07001011 skip |= LogWarning(object, kVUID_PVError_NONE,
1012 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1013 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1014 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001015 }
1016
1017 // height
1018 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001019 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001020 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001021
1022 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1023 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001024 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1025 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001026 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1027 height_healthy = false;
1028
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001029 skip |= LogError(object, "VUID-VkViewport-height-01773",
1030 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1031 ").",
1032 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001033 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1034 height_healthy = false;
1035
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001036 skip |= LogWarning(
1037 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001038 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001039 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001040 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001041 }
1042
1043 // x
1044 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001045 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001046 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001047 skip |= LogError(object, "VUID-VkViewport-x-01774",
1048 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1049 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001050 }
1051
1052 // x + width
1053 if (x_healthy && width_healthy) {
1054 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001055 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001056 skip |= LogError(
1057 object, "VUID-VkViewport-x-01232",
1058 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1059 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1060 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001061 }
1062 }
1063
1064 // y
1065 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001066 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001067 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001068 skip |= LogError(object, "VUID-VkViewport-y-01775",
1069 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1070 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001071 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001072 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001073 skip |= LogError(object, "VUID-VkViewport-y-01776",
1074 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1075 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001076 }
1077
1078 // y + height
1079 if (y_healthy && height_healthy) {
1080 const float boundary = viewport.y + viewport.height;
1081
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001082 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001083 skip |= LogError(object, "VUID-VkViewport-y-01233",
1084 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1085 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1086 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001087 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001088 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001089 LogError(object, "VUID-VkViewport-y-01777",
1090 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1091 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1092 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001093 }
1094 }
1095
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001096 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001097 // minDepth
1098 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001099 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001100
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001101 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1102 "[0.0, 1.0] range.",
1103 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001104 }
1105
1106 // maxDepth
1107 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001108 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001109
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001110 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1111 "[0.0, 1.0] range.",
1112 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001113 }
1114 }
1115
1116 return skip;
1117}
1118
Dave Houlton142c4cb2018-10-17 15:04:41 -06001119struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001120 VkShadingRatePaletteEntryNV shadingRate;
1121 uint32_t width;
1122 uint32_t height;
1123};
1124
1125// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001126static SampleOrderInfo sampleOrderInfos[] = {
1127 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1128 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1129 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1130 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1131 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1132 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001133};
1134
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001135bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001136 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001137
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001138 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001139 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001140 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001141 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001142 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001143 break;
1144 }
1145 }
1146
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001147 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001148 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1149 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1150 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001151 return skip;
1152 }
1153
Dave Houlton142c4cb2018-10-17 15:04:41 -06001154 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001155 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001156 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1157 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1158 ") must "
1159 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1160 "is set in framebufferNoAttachmentsSampleCounts.",
1161 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001162 }
1163
Jeff Bolz9af91c52018-09-01 21:53:57 -05001164 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001165 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1166 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1167 ") must "
1168 "be equal to the product of sampleCount (=%" PRIu32
1169 "), the fragment width for shadingRate "
1170 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1171 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001172 }
1173
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001174 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001175 skip |= LogError(
1176 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001177 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1178 ") must "
1179 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001180 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001181 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001182
1183 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001184 // the first width*height*sampleCount bits to all be set. Note: There is no
1185 // guarantee that 64 bits is enough, but practically it's unlikely for an
1186 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001187 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001188 uint64_t sampleLocationsMask = 0;
1189 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1190 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1191 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001192 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1193 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001194 }
1195 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001196 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1197 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001198 }
1199 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001200 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1201 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001202 }
1203 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1204 sampleLocationsMask |= 1ULL << idx;
1205 }
1206
1207 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1208 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001209 skip |= LogError(
1210 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001211 "The array pSampleLocations must contain exactly one entry for "
1212 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001213 }
1214
1215 return skip;
1216}
1217
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001218bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1219 uint32_t createInfoCount,
1220 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1221 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001222 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001223 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001224
1225 if (pCreateInfos != nullptr) {
1226 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001227 bool has_dynamic_viewport = false;
1228 bool has_dynamic_scissor = false;
1229 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001230 bool has_dynamic_depth_bias = false;
1231 bool has_dynamic_blend_constant = false;
1232 bool has_dynamic_depth_bounds = false;
1233 bool has_dynamic_stencil_compare = false;
1234 bool has_dynamic_stencil_write = false;
1235 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001236 bool has_dynamic_viewport_w_scaling_nv = false;
1237 bool has_dynamic_discard_rectangle_ext = false;
1238 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001239 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001240 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001241 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001242 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001243 if (pCreateInfos[i].pDynamicState != nullptr) {
1244 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1245 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1246 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001247 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1248 if (has_dynamic_viewport == true) {
1249 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1250 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1251 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1252 i);
1253 }
1254 has_dynamic_viewport = true;
1255 }
1256 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1257 if (has_dynamic_scissor == true) {
1258 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1259 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1260 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1261 i);
1262 }
1263 has_dynamic_scissor = true;
1264 }
1265 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1266 if (has_dynamic_line_width == true) {
1267 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1268 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1269 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1270 i);
1271 }
1272 has_dynamic_line_width = true;
1273 }
1274 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1275 if (has_dynamic_depth_bias == true) {
1276 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1277 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1278 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1279 i);
1280 }
1281 has_dynamic_depth_bias = true;
1282 }
1283 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1284 if (has_dynamic_blend_constant == true) {
1285 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1286 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1287 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1288 i);
1289 }
1290 has_dynamic_blend_constant = true;
1291 }
1292 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1293 if (has_dynamic_depth_bounds == true) {
1294 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1295 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1296 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1297 i);
1298 }
1299 has_dynamic_depth_bounds = true;
1300 }
1301 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1302 if (has_dynamic_stencil_compare == true) {
1303 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1304 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1305 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1306 i);
1307 }
1308 has_dynamic_stencil_compare = true;
1309 }
1310 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1311 if (has_dynamic_stencil_write == true) {
1312 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1313 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1314 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1315 i);
1316 }
1317 has_dynamic_stencil_write = true;
1318 }
1319 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1320 if (has_dynamic_stencil_reference == true) {
1321 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1322 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1323 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1324 i);
1325 }
1326 has_dynamic_stencil_reference = true;
1327 }
1328 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1329 if (has_dynamic_viewport_w_scaling_nv == true) {
1330 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1331 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1332 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1333 i);
1334 }
1335 has_dynamic_viewport_w_scaling_nv = true;
1336 }
1337 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1338 if (has_dynamic_discard_rectangle_ext == true) {
1339 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1340 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1341 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1342 i);
1343 }
1344 has_dynamic_discard_rectangle_ext = true;
1345 }
1346 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1347 if (has_dynamic_sample_locations_ext == true) {
1348 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1349 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1350 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1351 i);
1352 }
1353 has_dynamic_sample_locations_ext = true;
1354 }
1355 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1356 if (has_dynamic_exclusive_scissor_nv == true) {
1357 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1358 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1359 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1360 i);
1361 }
1362 has_dynamic_exclusive_scissor_nv = true;
1363 }
1364 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1365 if (has_dynamic_shading_rate_palette_nv == true) {
1366 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1367 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1368 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1369 i);
1370 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001371 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001372 }
1373 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1374 if (has_dynamic_viewport_course_sample_order_nv == true) {
1375 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1376 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1377 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1378 i);
1379 }
1380 has_dynamic_viewport_course_sample_order_nv = true;
1381 }
1382 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1383 if (has_dynamic_line_stipple == true) {
1384 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1385 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1386 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1387 i);
1388 }
1389 has_dynamic_line_stipple = true;
1390 }
Petr Kraus299ba622017-11-24 03:09:03 +01001391 }
1392 }
1393
Peter Chen85366392019-05-14 15:20:11 -04001394 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1395 if ((feedback_struct != nullptr) &&
1396 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001397 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1398 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1399 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1400 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1401 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001402 }
1403
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001404 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001405
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001406 // Collect active stages and other information
1407 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001408 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001409 bool has_eval = false;
1410 bool has_control = false;
1411 if (pCreateInfos[i].pStages != nullptr) {
1412 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1413 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1414
1415 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1416 has_control = true;
1417 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1418 has_eval = true;
1419 }
1420
1421 skip |= validate_string(
1422 "vkCreateGraphicsPipelines",
1423 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1424 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1425 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001426 }
1427
1428 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1429 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1430 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1431 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1432 pCreateInfos[i].pTessellationState,
1433 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1434 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1435
1436 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1437 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1438
1439 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1440 "VkPipelineTessellationDomainOriginStateCreateInfo",
1441 pCreateInfos[i].pTessellationState->pNext,
1442 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1443 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001444 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1445 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001446
1447 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1448 pCreateInfos[i].pTessellationState->flags,
1449 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1450 }
1451
1452 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1453 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1454 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1455 pCreateInfos[i].pInputAssemblyState,
1456 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1457 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1458
1459 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1460 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001461 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001462
1463 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1464 pCreateInfos[i].pInputAssemblyState->flags,
1465 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1466
1467 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1468 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1469 pCreateInfos[i].pInputAssemblyState->topology,
1470 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1471
1472 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1473 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1474 }
1475
1476 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001477 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001478
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001479 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001480 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1481 "vkCreateGraphicsPipelines: pararameter "
1482 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1483 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001484 }
1485
1486 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1487 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1488 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1489 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1490 pCreateInfos[i].pVertexInputState->pNext, 1,
1491 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001492 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1493 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001494 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1495 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001496 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001497 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1498 skip |=
1499 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1500 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1501 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1502 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1503 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1504
1505 skip |= validate_array(
1506 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1507 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1508 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1509 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1510
1511 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1512 for (uint32_t vertexBindingDescriptionIndex = 0;
1513 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1514 ++vertexBindingDescriptionIndex) {
1515 skip |= validate_ranged_enum(
1516 "vkCreateGraphicsPipelines",
1517 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1518 AllVkVertexInputRateEnums,
1519 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1520 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1521 }
1522 }
1523
1524 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1525 for (uint32_t vertexAttributeDescriptionIndex = 0;
1526 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1527 ++vertexAttributeDescriptionIndex) {
1528 skip |= validate_ranged_enum(
1529 "vkCreateGraphicsPipelines",
1530 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1531 AllVkFormatEnums,
1532 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1533 "VUID-VkVertexInputAttributeDescription-format-parameter");
1534 }
1535 }
1536
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001537 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001538 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1539 "vkCreateGraphicsPipelines: pararameter "
1540 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1541 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1542 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001543 }
1544
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001545 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001546 skip |=
1547 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1548 "vkCreateGraphicsPipelines: pararameter "
1549 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1550 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1551 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001552 }
1553
1554 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001555 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1556 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001557 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1558 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001559 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1560 "vkCreateGraphicsPipelines: parameter "
1561 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1562 "(%" PRIu32 ") is not distinct.",
1563 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001564 }
1565 vertex_bindings.insert(vertex_bind_desc.binding);
1566
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001567 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001568 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1569 "vkCreateGraphicsPipelines: parameter "
1570 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1571 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1572 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001573 }
1574
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001575 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001576 skip |=
1577 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1578 "vkCreateGraphicsPipelines: parameter "
1579 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1580 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1581 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001582 }
1583 }
1584
Peter Kohautc7d9d392018-07-15 00:34:07 +02001585 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001586 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1587 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001588 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1589 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001590 skip |= LogError(
1591 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001592 "vkCreateGraphicsPipelines: parameter "
1593 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1594 i, d, vertex_attrib_desc.location);
1595 }
1596 attribute_locations.insert(vertex_attrib_desc.location);
1597
1598 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1599 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001600 skip |= LogError(
1601 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001602 "vkCreateGraphicsPipelines: parameter "
1603 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1604 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1605 i, d, vertex_attrib_desc.binding, i);
1606 }
1607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001608 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001609 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1610 "vkCreateGraphicsPipelines: parameter "
1611 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1612 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1613 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001614 }
1615
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001616 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001617 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1618 "vkCreateGraphicsPipelines: parameter "
1619 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1620 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1621 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001622 }
1623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001624 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001625 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1626 "vkCreateGraphicsPipelines: parameter "
1627 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1628 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1629 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001630 }
1631 }
1632 }
1633
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001634 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1635 if (has_control && has_eval) {
1636 if (pCreateInfos[i].pTessellationState == nullptr) {
1637 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1638 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1639 "shader stage and a tessellation evaluation shader stage, "
1640 "pCreateInfos[%d].pTessellationState must not be NULL.",
1641 i, i);
1642 } else {
1643 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1644 skip |= validate_struct_pnext(
1645 "vkCreateGraphicsPipelines",
1646 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1647 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1648 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1649 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001650
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001651 skip |= validate_reserved_flags(
1652 "vkCreateGraphicsPipelines",
1653 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1654 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001655
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001656 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1657 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1658 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1659 "vkCreateGraphicsPipelines: invalid parameter "
1660 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1661 "should be >0 and <=%u.",
1662 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1663 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001664 }
1665 }
1666 }
1667
1668 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1669 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1670 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1671 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001672 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1673 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1674 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1675 "].pViewportState (=NULL) is not a valid pointer.",
1676 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001677 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001678 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1679
1680 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001681 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1682 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1683 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1684 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001685 }
1686
Petr Krausa6103552017-11-16 21:21:58 +01001687 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1688 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001689 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1690 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001691 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1692 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001693 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001694 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001695 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001696 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001697 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001698 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1699 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001700 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001701 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1702 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001703
1704 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001705 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001706 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001707 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001708
Dave Houlton142c4cb2018-10-17 15:04:41 -06001709 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1710 pCreateInfos[i].pViewportState->pNext);
1711 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1712 pCreateInfos[i].pViewportState->pNext);
1713 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1714 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001715 const auto vp_swizzle_struct =
1716 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001717 const auto vp_w_scaling_struct =
1718 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001719
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001720 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001721 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001722 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1723 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1724 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1725 ") is not 1.",
1726 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001727 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001728
Petr Krausa6103552017-11-16 21:21:58 +01001729 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001730 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1731 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1732 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1733 ") is not 1.",
1734 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001735 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001736
Dave Houlton142c4cb2018-10-17 15:04:41 -06001737 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1738 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001739 skip |= LogError(
1740 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1741 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1742 "disabled, but pCreateInfos[%" PRIu32
1743 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1744 ") is not 1.",
1745 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001746 }
1747
Jeff Bolz9af91c52018-09-01 21:53:57 -05001748 if (shading_rate_image_struct &&
1749 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001750 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1751 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1752 "disabled, but pCreateInfos[%" PRIu32
1753 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1754 ") is neither 0 nor 1.",
1755 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001756 }
1757
Petr Krausa6103552017-11-16 21:21:58 +01001758 } else { // multiViewport enabled
1759 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001760 skip |= LogError(
1761 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001762 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001763 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001764 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1765 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1766 "].pViewportState->viewportCount (=%" PRIu32
1767 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1768 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001769 }
Petr Krausa6103552017-11-16 21:21:58 +01001770
1771 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001772 skip |= LogError(
1773 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001774 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001775 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001776 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1777 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1778 "].pViewportState->scissorCount (=%" PRIu32
1779 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1780 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001781 }
1782 }
1783
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001784 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001785 skip |=
1786 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1787 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1788 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1789 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001790 }
1791
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001792 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001793 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1794 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1795 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1796 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1797 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001798 }
1799
Petr Krausa6103552017-11-16 21:21:58 +01001800 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001801 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1802 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1803 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1804 "].pViewportState->viewportCount (=%" PRIu32 ").",
1805 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001806 }
1807
Dave Houlton142c4cb2018-10-17 15:04:41 -06001808 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001809 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001810 skip |=
1811 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1812 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1813 ") must be zero or identical to pCreateInfos[%" PRIu32
1814 "].pViewportState->viewportCount (=%" PRIu32 ").",
1815 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001816 }
1817
Dave Houlton142c4cb2018-10-17 15:04:41 -06001818 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001819 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001820 skip |= LogError(
1821 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001822 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1823 "] "
1824 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1825 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1826 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001827 }
1828
Petr Krausa6103552017-11-16 21:21:58 +01001829 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001830 skip |= LogError(
1831 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001832 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1833 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001834 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1835 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001836 }
1837
1838 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001839 skip |= LogError(
1840 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001841 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1842 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001843 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1844 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001845 }
1846
Jeff Bolz3e71f782018-08-29 23:15:45 -05001847 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001848 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1849 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1850 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001851 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1852 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1853 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1854 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1855 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001856 }
1857
Jeff Bolz9af91c52018-09-01 21:53:57 -05001858 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001859 shading_rate_image_struct->viewportCount > 0 &&
1860 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001861 skip |= LogError(
1862 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001863 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001864 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1865 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001866 i, i);
1867 }
1868
Chris Mayer328d8212018-12-11 14:16:18 +01001869 if (vp_swizzle_struct) {
1870 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1872 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1873 " does "
1874 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1875 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001876 }
1877 }
1878
Petr Krausb3fcdb42018-01-09 22:09:09 +01001879 // validate the VkViewports
1880 if (!has_dynamic_viewport && viewport_state.pViewports) {
1881 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1882 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001883 const char *fn_name = "vkCreateGraphicsPipelines";
1884 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1885 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1886 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001887 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001888 }
1889 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001890
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001891 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001892 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1893 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1894 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1895 "VK_NV_clip_space_w_scaling extension is not enabled.",
1896 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001897 }
1898
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001899 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1901 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1902 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1903 "VK_EXT_discard_rectangles extension is not enabled.",
1904 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001905 }
1906
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001907 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001908 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1909 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1910 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1911 "VK_EXT_sample_locations extension is not enabled.",
1912 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001913 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001914
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001915 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001916 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1917 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1918 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1919 "VK_NV_scissor_exclusive extension is not enabled.",
1920 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001921 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001922
1923 if (coarse_sample_order_struct &&
1924 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1925 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001926 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1927 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1928 "] "
1929 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1930 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1931 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001932 }
1933
1934 if (coarse_sample_order_struct) {
1935 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001936 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001937 }
1938 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001939
1940 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1941 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001942 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1943 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1944 "] "
1945 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1946 ") "
1947 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1948 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001949 }
1950 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001951 skip |= LogError(
1952 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001953 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1954 "] "
1955 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1956 i);
1957 }
1958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001959 }
1960
1961 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001962 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1963 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1964 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1965 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001966 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001967 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1968 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1969 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001970 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001971 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001972 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001973 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001974 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001975 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001976 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001977 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1978 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979
1980 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001981 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001982 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001983 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001984
1985 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001986 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1988 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1989
1990 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001991 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001992 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1993 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001994 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001995 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001996
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001997 skip |= validate_flags(
1998 "vkCreateGraphicsPipelines",
1999 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2000 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002001 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002002
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002003 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002004 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002005 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2006 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2007
2008 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002009 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002010 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2011 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2012
2013 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002014 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2015 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2016 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2017 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002018 }
John Zulauf7acac592017-11-06 11:15:53 -07002019 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002020 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002021 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2022 "vkCreateGraphicsPipelines(): parameter "
2023 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2024 i);
John Zulauf7acac592017-11-06 11:15:53 -07002025 }
2026 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2027 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2028 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002029 skip |= LogError(
2030 device,
2031
Dave Houlton413a6782018-05-22 13:01:54 -06002032 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002033 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002034 }
2035 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002036
2037 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2038 pCreateInfos[i].pRasterizationState->pNext);
2039
2040 if (line_state) {
2041 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2042 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2043 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2044 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002045 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2046 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2047 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2048 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002049 }
2050 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002052 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2053 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2054 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2055 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002056 }
2057 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2058 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002059 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2060 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2061 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2062 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002063 }
2064 }
2065 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2066 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2067 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002068 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2069 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2070 "range [1,256].",
2071 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002072 }
2073 }
2074 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002075 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002076 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2077 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002078 skip |=
2079 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2080 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2081 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2082 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002083 }
2084 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2085 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002086 skip |=
2087 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2088 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2089 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2090 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002091 }
2092 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2093 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002094 skip |=
2095 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2096 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2097 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2098 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002099 }
2100 if (line_state->stippledLineEnable) {
2101 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2102 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002103 skip |=
2104 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2105 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2106 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2107 "stippledRectangularLines feature.",
2108 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002109 }
2110 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2111 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002112 skip |=
2113 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2114 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2115 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2116 "stippledBresenhamLines feature.",
2117 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002118 }
2119 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2120 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002121 skip |=
2122 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2123 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2124 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2125 "stippledSmoothLines feature.",
2126 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002127 }
2128 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2129 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002130 skip |=
2131 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2132 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2133 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2134 "stippledRectangularLines and strictLines features.",
2135 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002136 }
2137 }
2138 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002139 }
2140
Petr Krause91f7a12017-12-14 20:57:36 +01002141 bool uses_color_attachment = false;
2142 bool uses_depthstencil_attachment = false;
2143 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002144 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002145 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2146 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002147 const auto &subpasses_uses = subpasses_uses_it->second;
2148 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2149 uses_color_attachment = true;
2150 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2151 uses_depthstencil_attachment = true;
2152 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002153 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002154 }
2155
2156 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002157 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002158 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002159 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002160 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002161 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002162
2163 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002164 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002165 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002166 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002167
2168 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2171 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2172
2173 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2176 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2177
2178 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2181 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002182 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002183
2184 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002185 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2187 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2188
2189 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002190 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002191 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2192 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2193
2194 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002195 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002196 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2197 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002198 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002199
2200 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002201 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002202 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2203 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002204 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205
2206 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2209 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002210 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211
2212 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002214 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2215 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002216 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002217
2218 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002219 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002220 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2221 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002222 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002223
2224 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002225 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2227 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002228 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229
2230 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002232 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2233 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002234 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002235
2236 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002237 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002238 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2239 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002240 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241
2242 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2244 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2245 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2246 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002247 }
2248 }
2249
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002250 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2251 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2252
Petr Krause91f7a12017-12-14 20:57:36 +01002253 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002254 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2255 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2256 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2257 pCreateInfos[i].pColorBlendState,
2258 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2259 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2260
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002262 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002263 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2264 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2265 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002266 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002267 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2268 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269
2270 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002271 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002272 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002273 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002274
2275 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002276 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002277 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2278 pCreateInfos[i].pColorBlendState->logicOpEnable);
2279
2280 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2283 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002284 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002285 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002286
2287 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2288 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2289 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002290 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2292 ParameterName::IndexVector{i, attachmentIndex}),
2293 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2294
2295 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002296 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2298 ParameterName::IndexVector{i, attachmentIndex}),
2299 "VkBlendFactor", AllVkBlendFactorEnums,
2300 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002301 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002302
2303 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002304 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2306 ParameterName::IndexVector{i, attachmentIndex}),
2307 "VkBlendFactor", AllVkBlendFactorEnums,
2308 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002309 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002310
2311 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002312 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2314 ParameterName::IndexVector{i, attachmentIndex}),
2315 "VkBlendOp", AllVkBlendOpEnums,
2316 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002317 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318
2319 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002320 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2322 ParameterName::IndexVector{i, attachmentIndex}),
2323 "VkBlendFactor", AllVkBlendFactorEnums,
2324 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002325 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002326
2327 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002328 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2330 ParameterName::IndexVector{i, attachmentIndex}),
2331 "VkBlendFactor", AllVkBlendFactorEnums,
2332 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002333 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334
2335 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002336 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2338 ParameterName::IndexVector{i, attachmentIndex}),
2339 "VkBlendOp", AllVkBlendOpEnums,
2340 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002341 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342
2343 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002344 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002345 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2346 ParameterName::IndexVector{i, attachmentIndex}),
2347 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2348 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002349 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002350 }
2351 }
2352
2353 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002354 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2355 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2356 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2357 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002358 }
2359
2360 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2361 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2362 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002363 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002365 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2366 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367 }
2368 }
2369 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370
Petr Kraus9752aae2017-11-24 03:05:50 +01002371 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2372 if (pCreateInfos[i].basePipelineIndex != -1) {
2373 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |=
2375 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002376 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002377 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002378 "and pCreateInfos->basePipelineIndex is not -1.",
2379 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002380 }
2381 }
2382
Petr Kraus9752aae2017-11-24 03:05:50 +01002383 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2384 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002385 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002386 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002387 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002388 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2389 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002390 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002391 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002392 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002393 skip |=
2394 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2395 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2396 "index into the pCreateInfos array, of size %d.",
2397 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002398 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002399 }
2400 }
2401
sfricke-samsung898cf222020-05-15 23:10:19 -07002402 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2403 skip |= LogError(
2404 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2405 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2406 i);
2407 }
2408
Petr Kraus9752aae2017-11-24 03:05:50 +01002409 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002410 if (!device_extensions.vk_nv_fill_rectangle) {
2411 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2412 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002413 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2414 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2415 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2416 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002417 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2418 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2420 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002421 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2422 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2423 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002424 }
2425 } else {
2426 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2427 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2428 (physical_device_features.fillModeNonSolid == false)) {
2429 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002430 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2431 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002432 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2433 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2434 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002435 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
Petr Kraus299ba622017-11-24 03:09:03 +01002437
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002438 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002439 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002440 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2441 "The line width state is static (pCreateInfos[%" PRIu32
2442 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2443 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2444 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2445 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002446 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002447 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002448 }
2449 }
2450
2451 return skip;
2452}
2453
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002454bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2455 uint32_t createInfoCount,
2456 const VkComputePipelineCreateInfo *pCreateInfos,
2457 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002458 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002460 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002461 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002463 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002464 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2465 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002466 skip |=
2467 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2468 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2469 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2470 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002471 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002472
2473 // Make sure compute stage is selected
2474 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002475 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2476 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2477 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002478 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002480 return skip;
2481}
2482
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002483bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002484 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002486
2487 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002488 const auto &features = physical_device_features;
2489 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002490
John Zulauf71968502017-10-26 13:51:15 -06002491 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2492 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2494 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2495 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2496 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002497 }
2498
2499 // Anistropy cannot be enabled in sampler unless enabled as a feature
2500 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002501 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2502 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2503 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002504 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002505 }
John Zulauf71968502017-10-26 13:51:15 -06002506
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002507 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2508 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002509 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2510 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2511 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2512 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002513 }
2514 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002515 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2516 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2517 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2518 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002519 }
2520 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002521 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2522 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2523 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2524 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002525 }
2526 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2527 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2528 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2529 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2531 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2532 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2533 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2534 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2535 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002536 }
2537 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002538 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2539 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2540 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002541 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002542 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002543 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2544 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2545 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002546 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002547 }
2548
2549 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2550 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002551 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2552 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002553 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2554 if (sampler_reduction != nullptr) {
2555 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2556 skip |= LogError(
2557 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2558 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2559 }
2560 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 }
2562
2563 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2564 // valid VkBorderColor value
2565 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2566 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2567 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002568 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2569 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002570 }
2571
2572 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2573 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002575 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2576 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2577 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002578 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2580 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2581 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002582 }
John Zulauf275805c2017-10-26 15:34:49 -06002583
2584 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002585 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002586 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2587 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002588 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2589 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2590 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002591 }
2592 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002593
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002594 // Check for valid Lod range
2595 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002596 skip |=
2597 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2598 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002599 }
2600
2601 // Check mipLodBias to device limit
2602 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002603 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2604 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2605 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002606 }
2607
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002608 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2609 if (sampler_conversion != nullptr) {
2610 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2611 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2612 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2613 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002614 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002615 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002616 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2617 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2618 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2619 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2620 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2621 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2622 }
2623 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002624
2625 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2626 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2627 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2628 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2629 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2630 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2631 }
2632 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2633 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2634 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2635 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2636 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2637 }
2638 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2639 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2640 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2641 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2642 pCreateInfo->minLod, pCreateInfo->maxLod);
2643 }
2644 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2645 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2646 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2647 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2648 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2649 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2650 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2651 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2652 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2653 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2654 }
2655 if (pCreateInfo->anisotropyEnable) {
2656 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2657 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2658 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2659 }
2660 if (pCreateInfo->compareEnable) {
2661 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2662 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2663 "pCreateInfo->compareEnable must be VK_FALSE");
2664 }
2665 if (pCreateInfo->unnormalizedCoordinates) {
2666 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2667 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2668 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2669 }
2670 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002671 }
2672
Tony-LunarG7337b312020-04-15 16:40:25 -06002673 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2674 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2675 if (!device_extensions.vk_ext_custom_border_color) {
2676 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2677 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2678 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2679 }
2680 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2681 if (!custom_create_info) {
2682 skip |=
2683 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2684 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2685 "struct in pNext chain.\n",
2686 string_VkBorderColor(pCreateInfo->borderColor));
2687 } else {
2688 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2689 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2690 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2691 !FormatIsSampledFloat(custom_create_info->format)))) {
2692 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2693 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2694 "whose type does not match\n",
2695 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2696 ;
2697 }
2698 }
2699 }
2700
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002701 return skip;
2702}
2703
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002704bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2705 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2706 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002707 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002709
2710 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2711 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2712 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2713 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002714 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2715 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2716 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2717 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2718 ++descriptor_index) {
2719 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002720 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002721 "vkCreateDescriptorSetLayout: required parameter "
2722 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2723 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 }
2725 }
2726 }
2727
2728 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2729 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2730 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002731 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2732 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2733 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2734 "values.",
2735 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002736 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002737
2738 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2739 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2740 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2741 skip |=
2742 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2743 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2744 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2745 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2746 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2747 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 }
2749 }
2750 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002751 return skip;
2752}
2753
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002754bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2755 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002756 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2758 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2759 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002760 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2761 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002762}
2763
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002764bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2765 const VkWriteDescriptorSet *pDescriptorWrites,
2766 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002767 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002768
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769 if (pDescriptorWrites != NULL) {
2770 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2771 // descriptorCount must be greater than 0
2772 if (pDescriptorWrites[i].descriptorCount == 0) {
2773 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002774 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2775 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002776 }
2777
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002778 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2779 if (validateDstSet) {
2780 // dstSet must be a valid VkDescriptorSet handle
2781 skip |= validate_required_handle(vkCallingFunction,
2782 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2783 pDescriptorWrites[i].dstSet);
2784 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785
2786 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2787 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2788 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2789 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2790 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2791 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2792 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002793 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2794 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002795 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002796 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2797 "%s(): if pDescriptorWrites[%d].descriptorType is "
2798 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2799 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2800 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2801 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2803 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002804 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2805 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002806 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2807 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002808 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2810 ParameterName::IndexVector{i, descriptor_index}),
2811 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002812 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002813 }
2814 }
2815 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2816 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2817 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2818 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2819 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2820 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2821 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002822 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002823 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2825 "%s(): if pDescriptorWrites[%d].descriptorType is "
2826 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2827 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2828 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2829 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002831 const auto *robustness2_features =
2832 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2833 if (robustness2_features && robustness2_features->nullDescriptor) {
2834 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2835 ++descriptorIndex) {
2836 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2837 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2838 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2839 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2840 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2841 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2842 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2843 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2844 }
2845 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002846 }
2847 }
2848 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2849 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002850 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002851 }
2852
2853 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2854 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002855 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2857 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2858 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002859 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2861 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2862 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2863 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002864 }
2865 }
2866 }
2867 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2868 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002869 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2871 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2872 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002873 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002874 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2875 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2876 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2877 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002878 }
2879 }
2880 }
2881 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002882 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2883 // or VkWriteDescriptorSetInlineUniformBlockEX
2884 if (pDescriptorWrites[i].pNext) {
2885 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2886 const auto *pNext_struct =
2887 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2888 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2889 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2890 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2891 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2892 "accelerationStructureCount %d member equals descriptorCount %d.",
2893 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2894 pDescriptorWrites[i].descriptorCount);
2895 }
2896 // further checks only if we have right structtype
2897 if (pNext_struct) {
2898 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2899 skip |= LogError(
2900 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2901 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2902 ".",
2903 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2904 }
2905 if (pNext_struct->accelerationStructureCount == 0) {
2906 skip |= LogError(
2907 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2908 "%s(): accelerationStructureCount must be greater than 0 .");
2909 }
2910 }
2911 }
2912 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002913 }
2914 }
2915 return skip;
2916}
2917
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002918bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2919 const VkWriteDescriptorSet *pDescriptorWrites,
2920 uint32_t descriptorCopyCount,
2921 const VkCopyDescriptorSet *pDescriptorCopies) const {
2922 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2923}
2924
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002925bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002926 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002927 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002928 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2929}
2930
2931bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002932 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002933 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002934 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2935}
2936
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002937bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2938 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002939 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002941
2942 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2943 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2944 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002945 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2946 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947 return skip;
2948}
2949
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002950bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002951 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002952 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002953
2954 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2955 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2957
Petr Krause7bb9e82019-08-11 21:34:43 +02002958 // Implicit VUs
2959 // validate only sType here; pointer has to be validated in core_validation
2960 const bool kNotRequired = false;
2961 const char *kNoVUID = nullptr;
2962 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2963 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2964 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002965
Petr Krause7bb9e82019-08-11 21:34:43 +02002966 if (pInfo) {
2967 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2968 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2969 skip |= validate_struct_pnext(
2970 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2971 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002972 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2973 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002974
Petr Krause7bb9e82019-08-11 21:34:43 +02002975 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002976
Petr Krause7bb9e82019-08-11 21:34:43 +02002977 // Explicit VUs
2978 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002979 skip |= LogError(
2980 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002981 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2982 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002983 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002984
2985 if (physical_device_features.inheritedQueries) {
2986 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002987 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002988 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002989 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002990 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002991 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002992 }
2993
2994 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002995 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002996 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002997 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002998 } else { // !pipelineStatisticsQuery
2999 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3000 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003001 }
Petr Kraus139757b2019-08-15 17:19:33 +02003002
3003 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3004 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003005 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003006 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3007 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003008 skip |= LogError(
3009 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003010 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3011 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3012 }
3013 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003014 }
3015
3016 return skip;
3017}
3018
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003019bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003020 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003022
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003023 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003024 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3026 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3027 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003028 }
3029 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003030 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3031 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3032 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003033 }
3034 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003035 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003036 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003037 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3038 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3039 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3040 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003041 }
3042 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003043
3044 if (pViewports) {
3045 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3046 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003047 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003048 skip |= manual_PreCallValidateViewport(
3049 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003050 }
3051 }
3052
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 return skip;
3054}
3055
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003056bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003057 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003058 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003060 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003061 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003062 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3063 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3064 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003065 }
3066 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003067 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3068 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3069 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003070 }
3071 } else { // multiViewport enabled
3072 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003073 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003074 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3075 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3076 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3077 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078 }
3079 }
3080
Petr Kraus6260f0a2018-02-27 21:15:55 +01003081 if (pScissors) {
3082 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3083 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003084
Petr Kraus6260f0a2018-02-27 21:15:55 +01003085 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003086 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3087 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3088 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003089 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090
Petr Kraus6260f0a2018-02-27 21:15:55 +01003091 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003092 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3093 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3094 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003095 }
3096
3097 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3098 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003099 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3100 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3101 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3102 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003103 }
3104
3105 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3106 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003107 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3108 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3109 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3110 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003111 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003112 }
3113 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003114
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 return skip;
3116}
3117
Jeff Bolz5c801d12019-10-09 10:38:45 -05003118bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003119 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003120
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003121 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003122 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3123 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003124 }
3125
3126 return skip;
3127}
3128
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003129bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003130 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 if (vertexCount == 0) {
3133 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3134 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003135 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136 }
3137
3138 if (instanceCount == 0) {
3139 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3140 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 }
3143 return skip;
3144}
3145
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003146bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003147 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003150 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003151 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3152 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003153 }
3154 return skip;
3155}
3156
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003157bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003158 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003160 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003161 skip |=
3162 LogError(device, kVUID_PVError_DeviceFeature,
3163 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003164 }
3165 return skip;
3166}
3167
sfricke-samsungf692b972020-05-02 08:00:45 -07003168bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3169 VkDeviceSize countBufferOffset, bool khr) const {
3170 bool skip = false;
3171 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3172 if (offset & 3) {
3173 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3174 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3175 }
3176
3177 if (countBufferOffset & 3) {
3178 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3179 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3180 countBufferOffset);
3181 }
3182 return skip;
3183}
3184
3185bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3186 VkDeviceSize offset, VkBuffer countBuffer,
3187 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3188 uint32_t stride) const {
3189 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3190}
3191
3192bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3193 VkDeviceSize offset, VkBuffer countBuffer,
3194 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3195 uint32_t stride) const {
3196 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3197}
3198
3199bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3200 VkDeviceSize countBufferOffset, bool khr) const {
3201 bool skip = false;
3202 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3203 if (offset & 3) {
3204 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3205 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3206 }
3207
3208 if (countBufferOffset & 3) {
3209 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3210 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3211 countBufferOffset);
3212 }
3213 return skip;
3214}
3215
3216bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3217 VkDeviceSize offset, VkBuffer countBuffer,
3218 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3219 uint32_t stride) const {
3220 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3221}
3222
3223bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3224 VkDeviceSize offset, VkBuffer countBuffer,
3225 VkDeviceSize countBufferOffset,
3226 uint32_t maxDrawCount, uint32_t stride) const {
3227 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3228}
3229
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003230bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3231 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003232 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003233 bool skip = false;
3234 for (uint32_t rect = 0; rect < rectCount; rect++) {
3235 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003236 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3237 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003238 }
sfricke-samsung10867682020-04-25 02:20:39 -07003239 if (pRects[rect].rect.extent.width == 0) {
3240 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3241 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3242 }
3243 if (pRects[rect].rect.extent.height == 0) {
3244 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3245 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3246 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003247 }
3248 return skip;
3249}
3250
Andrew Fobel3abeb992020-01-20 16:33:22 -05003251bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3252 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3253 VkImageFormatProperties2 *pImageFormatProperties,
3254 const char *apiName) const {
3255 bool skip = false;
3256
3257 if (pImageFormatInfo != nullptr) {
3258 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3259 if (image_stencil_struct != nullptr) {
3260 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3261 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3262 // No flags other than the legal attachment bits may be set
3263 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3264 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003265 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3266 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3267 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3268 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3269 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003270 }
3271 }
3272 }
3273 }
3274
3275 return skip;
3276}
3277
3278bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3279 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3280 VkImageFormatProperties2 *pImageFormatProperties) const {
3281 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3282 "vkGetPhysicalDeviceImageFormatProperties2");
3283}
3284
3285bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3286 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3287 VkImageFormatProperties2 *pImageFormatProperties) const {
3288 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3289 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3290}
3291
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003292bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3293 VkImageLayout srcImageLayout, VkImage dstImage,
3294 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003295 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003296 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003297
Dave Houltonf5217612018-02-02 16:18:52 -07003298 VkImageAspectFlags legal_aspect_flags =
3299 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 -07003300 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003301 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3302 }
3303
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003304 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003305 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003306 skip |= LogError(
3307 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003308 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003309 }
Dave Houltonf5217612018-02-02 16:18:52 -07003310 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003311 skip |= LogError(
3312 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003313 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 }
3315 }
3316 return skip;
3317}
3318
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003319bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3320 VkImageLayout srcImageLayout, VkImage dstImage,
3321 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003322 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003323 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003324
Dave Houltonf5217612018-02-02 16:18:52 -07003325 VkImageAspectFlags legal_aspect_flags =
3326 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 -07003327 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003328 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3329 }
3330
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003331 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003332 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003333 skip |= LogError(
3334 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3336 }
Dave Houltonf5217612018-02-02 16:18:52 -07003337 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003338 skip |= LogError(
3339 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003340 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3341 }
3342 }
3343 return skip;
3344}
3345
sfricke-samsung3999ef62020-02-09 17:05:59 -08003346bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3347 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3348 bool skip = false;
3349
3350 if (pRegions != nullptr) {
3351 for (uint32_t i = 0; i < regionCount; i++) {
3352 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003353 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3354 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003355 }
3356 }
3357 }
3358 return skip;
3359}
3360
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003361bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3362 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003363 uint32_t regionCount,
3364 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003365 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366
Dave Houltonf5217612018-02-02 16:18:52 -07003367 VkImageAspectFlags legal_aspect_flags =
3368 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 -07003369 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003370 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3371 }
3372
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003373 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003374 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003375 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3376 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3377 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003378 }
3379 }
3380 return skip;
3381}
3382
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003383bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3384 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003385 uint32_t regionCount,
3386 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003387 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388
Dave Houltonf5217612018-02-02 16:18:52 -07003389 VkImageAspectFlags legal_aspect_flags =
3390 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 -07003391 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003392 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3393 }
3394
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003396 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003397 skip |= LogError(
3398 device, kVUID_PVError_UnrecognizedValue,
3399 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3400 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 }
3402 }
3403 return skip;
3404}
3405
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003406bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003407 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3408 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003410
3411 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003412 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3413 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3414 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003415 }
3416
3417 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003418 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3419 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3420 "), must be greater than zero and less than or equal to 65536.",
3421 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003423 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3424 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3425 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 }
3427 return skip;
3428}
3429
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003430bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003431 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433
3434 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003435 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3436 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3437 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 }
3439
3440 if (size != VK_WHOLE_SIZE) {
3441 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003442 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003443 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3444 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003445 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003446 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3447 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003448 }
3449 }
3450 return skip;
3451}
3452
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003453bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003454 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003455 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003457
3458 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003459 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3460 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3461 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3462 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003463 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3464 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3465 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003466 }
3467
3468 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3469 // queueFamilyIndexCount uint32_t values
3470 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003471 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3472 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3473 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3474 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003475 }
3476 }
3477
Dave Houlton413a6782018-05-22 13:01:54 -06003478 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003480 }
3481
3482 return skip;
3483}
3484
Jeff Bolz5c801d12019-10-09 10:38:45 -05003485bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487
3488 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003489 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3490 if (present_regions) {
3491 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003492 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003493 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3494 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003495 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3496 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3497 "extension swapchainCount is %i. These values must be equal.",
3498 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003499 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003500 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003501 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3502 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003503 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3504 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3505 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003506 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003507 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003508 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003509 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003510 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 }
3512 }
3513
3514 return skip;
3515}
3516
3517#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003518bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3519 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3520 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003521 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003522 bool skip = false;
3523
3524 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003525 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3526 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003527 }
3528
3529 return skip;
3530}
3531#endif // VK_USE_PLATFORM_WIN32_KHR
3532
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003533bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003534 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003535 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003536 bool skip = false;
3537
3538 if (pCreateInfo) {
3539 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3541 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003542 }
3543
3544 if (pCreateInfo->pPoolSizes) {
3545 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3546 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003547 skip |= LogError(
3548 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003549 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003550 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003551 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3552 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003553 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3554 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3555 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3556 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3557 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003558 }
Petr Krausc8655be2017-09-27 18:56:51 +02003559 }
3560 }
3561 }
3562
3563 return skip;
3564}
3565
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003566bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003567 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003568 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003569
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003570 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003571 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003572 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3573 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3574 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003575 }
3576
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003577 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003578 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003579 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3580 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3581 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003582 }
3583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003584 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003585 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3587 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3588 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003589 }
3590
3591 return skip;
3592}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003593
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003594bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003595 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003596 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003597
3598 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003599 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3600 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003601 }
3602 return skip;
3603}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003604
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003605bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3606 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003607 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003608 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003609
3610 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003611 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003612 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003613 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3614 "vkCmdDispatch(): baseGroupX (%" PRIu32
3615 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3616 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003617 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3619 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3620 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3621 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003622 }
3623
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003624 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003625 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3627 "vkCmdDispatch(): baseGroupY (%" PRIu32
3628 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3629 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003630 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003631 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3632 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3633 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3634 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003635 }
3636
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003637 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003638 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003639 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3640 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3641 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3642 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003643 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003644 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3645 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3646 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3647 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003648 }
3649
3650 return skip;
3651}
3652
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003653bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3654 VkPipelineBindPoint pipelineBindPoint,
3655 VkPipelineLayout layout, uint32_t set,
3656 uint32_t descriptorWriteCount,
3657 const VkWriteDescriptorSet *pDescriptorWrites) const {
3658 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3659}
3660
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003661bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3662 uint32_t firstExclusiveScissor,
3663 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003664 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003665 bool skip = false;
3666
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003667 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003668 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003669 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3671 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3672 ") is not 0.",
3673 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003674 }
3675 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003676 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003677 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3678 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3679 ") is not 1.",
3680 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003681 }
3682 } else { // multiViewport enabled
3683 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003684 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3686 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3687 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3688 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003689 }
3690 }
3691
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003692 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003693 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3694 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3695 ") must be less than maxViewports (=%" PRIu32 ").",
3696 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003697 }
3698
3699 if (pExclusiveScissors) {
3700 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3701 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3702
3703 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003704 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3705 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3706 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003707 }
3708
3709 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003710 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3711 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3712 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003713 }
3714
3715 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3716 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3718 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3719 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3720 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003721 }
3722
3723 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3724 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003725 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3726 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3727 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3728 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003729 }
3730 }
3731 }
3732
3733 return skip;
3734}
3735
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003736bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3737 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003738 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003739 bool skip = false;
3740 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003741 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3742 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3743 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003744 } else {
3745 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3746 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003747 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3748 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3749 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3750 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003751 }
3752 }
3753
3754 return skip;
3755}
3756
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003757bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3758 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003759 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003760 bool skip = false;
3761
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003762 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003763 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003764 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003765 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3766 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3767 ") is not 0.",
3768 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003769 }
3770 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003771 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003772 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3773 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3774 ") is not 1.",
3775 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003776 }
3777 }
3778
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003779 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003780 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3781 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3782 ") must be less than maxViewports (=%" PRIu32 ").",
3783 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003784 }
3785
3786 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003787 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003788 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3789 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3790 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3791 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003792 }
3793
3794 return skip;
3795}
3796
Jeff Bolz5c801d12019-10-09 10:38:45 -05003797bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3798 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3799 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003800 bool skip = false;
3801
Dave Houlton142c4cb2018-10-17 15:04:41 -06003802 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003803 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3804 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3805 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003806 }
3807
3808 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003809 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003810 }
3811
3812 return skip;
3813}
3814
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003815bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003816 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003817 bool skip = false;
3818
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003819 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= LogError(
3821 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003822 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3823 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003824 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003825 }
3826
3827 return skip;
3828}
3829
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003830bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3831 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003832 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003833 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003834 static const int condition_multiples = 0b0011;
3835 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003836 skip |= LogError(
3837 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003838 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003839 }
Lockee1c22882019-06-10 16:02:54 -06003840 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003841 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3842 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3843 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3844 stride);
Lockee1c22882019-06-10 16:02:54 -06003845 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003846 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003847 skip |= LogError(
3848 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3849 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003850 }
3851
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003852 return skip;
3853}
3854
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003855bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3856 VkDeviceSize offset, VkBuffer countBuffer,
3857 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003858 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003859 bool skip = false;
3860
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003861 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003862 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3863 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3864 "), is not a multiple of 4.",
3865 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003866 }
3867
3868 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003869 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3870 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3871 "), is not a multiple of 4.",
3872 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003873 }
3874
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003875 return skip;
3876}
3877
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003878bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003879 const VkAllocationCallbacks *pAllocator,
3880 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003881 bool skip = false;
3882
3883 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3884 if (pCreateInfo != nullptr) {
3885 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3886 // VkQueryPipelineStatisticFlagBits values
3887 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3888 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3890 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3891 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3892 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003893 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003894 if (pCreateInfo->queryCount == 0) {
3895 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3896 "vkCreateQueryPool(): queryCount must be greater than zero.");
3897 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003898 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003899 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003900}
3901
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003902bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3903 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003904 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003905 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3906 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003907}
3908
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003909void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003910 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3911 VkResult result) {
3912 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003913 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003914}
3915
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003916void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003917 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3918 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003919 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003920 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003921 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003922}
3923
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003924void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3925 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003926 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003927 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003928 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003929}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003930
3931bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003932 const VkAllocationCallbacks *pAllocator,
3933 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003934 bool skip = false;
3935
3936 if (pAllocateInfo) {
3937 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3938 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003939 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3940 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003941 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003942
3943 VkMemoryAllocateFlags flags = 0;
3944 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3945 if (flags_info) {
3946 flags = flags_info->flags;
3947 }
3948
3949 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3950 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3951 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003952 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3953 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3954 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003955 }
3956
3957#ifdef VK_USE_PLATFORM_WIN32_KHR
3958 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3959#endif
3960 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3961 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3962#ifdef VK_USE_PLATFORM_ANDROID_KHR
3963 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3964#endif
3965
3966 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003967 skip |= LogError(
3968 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003969 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3970 }
3971 if (
3972#ifdef VK_USE_PLATFORM_WIN32_KHR
3973 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3974#endif
3975 (import_memory_fd && import_memory_fd->handleType) ||
3976#ifdef VK_USE_PLATFORM_ANDROID_KHR
3977 (import_memory_ahb && import_memory_ahb->buffer) ||
3978#endif
3979 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003980 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3981 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003982 }
3983 }
3984
3985 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003986 VkBool32 capture_replay = false;
3987 VkBool32 buffer_device_address = false;
3988 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3989 if (vulkan_12_features) {
3990 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3991 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3992 } else {
3993 const auto *bda_features =
3994 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3995 if (bda_features) {
3996 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3997 buffer_device_address = bda_features->bufferDeviceAddress;
3998 }
3999 }
4000 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004001 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4002 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4003 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004004 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004005 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004006 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4007 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004008 }
4009 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004010 }
4011 return skip;
4012}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004013
Jason Macnak192fa0e2019-07-26 15:07:16 -07004014bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004016 bool skip = false;
4017
4018 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4019 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4020 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004021 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004022 } else {
4023 uint32_t vertex_component_size = 0;
4024 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4025 vertex_component_size = 4;
4026 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4027 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4028 vertex_component_size = 2;
4029 }
4030 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004031 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004032 }
4033 }
4034
4035 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4036 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004037 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004038 } else {
4039 uint32_t index_element_size = 0;
4040 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4041 index_element_size = 4;
4042 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4043 index_element_size = 2;
4044 }
4045 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004046 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004047 }
4048 }
4049 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4050 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004051 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004052 }
4053 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004054 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004055 }
4056 }
4057
4058 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004059 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004060 }
4061
4062 return skip;
4063}
4064
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4066 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004067 bool skip = false;
4068
4069 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004070 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004071 }
4072 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004073 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004074 }
4075
4076 return skip;
4077}
4078
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004079bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4080 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004081 bool skip = false;
4082 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004084 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004085 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004086 }
4087 return skip;
4088}
4089
4090bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004091 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07004092 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004093 bool skip = false;
4094 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4096 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4097 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004098 }
4099 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004100 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4101 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4102 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004103 }
4104 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4105 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004106 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4107 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4108 "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 -07004109 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004110 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004111 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
4112 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4113 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004114 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004115 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004116 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4117 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4118 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004119 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004120 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004121 uint64_t total_triangle_count = 0;
4122 for (uint32_t i = 0; i < info.geometryCount; i++) {
4123 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004124
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004125 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004126
Jason Macnak5c954952019-07-09 15:46:12 -07004127 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4128 continue;
4129 }
4130 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4131 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004132 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004133 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4134 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4135 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004136 }
4137 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004138 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4139 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4140 for (uint32_t i = 1; i < info.geometryCount; i++) {
4141 const VkGeometryNV &geometry = info.pGeometries[i];
4142 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004143 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004144 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4145 "info.pGeometries[0].geometryType.",
4146 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004147 }
4148 }
4149 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004150 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4151 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4152 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4153 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4154 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4155 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4156 }
4157 }
4158 skip |=
4159 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
4160 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07004161 return skip;
4162}
4163
Ricardo Garciaa4935972019-02-21 17:43:18 +01004164bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4165 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004166 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004167 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004168 if (pCreateInfo) {
4169 if ((pCreateInfo->compactedSize != 0) &&
4170 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004171 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4172 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4173 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4174 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004175 }
Jason Macnak5c954952019-07-09 15:46:12 -07004176
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07004178 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01004179 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004180 return skip;
4181}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004182
Jeff Bolz5c801d12019-10-09 10:38:45 -05004183bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4184 const VkAccelerationStructureInfoNV *pInfo,
4185 VkBuffer instanceData, VkDeviceSize instanceOffset,
4186 VkBool32 update, VkAccelerationStructureNV dst,
4187 VkAccelerationStructureNV src, VkBuffer scratch,
4188 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004189 bool skip = false;
4190
4191 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004192 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004193 }
4194
4195 return skip;
4196}
4197
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004198bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4199 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4200 VkAccelerationStructureKHR *pAccelerationStructure) const {
4201 bool skip = false;
4202
4203 if (pCreateInfo) {
4204 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4205 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4206 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4207 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4208 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4209 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4210 i);
4211 }
4212 }
4213
4214 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4215 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4216 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4217 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4218 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4219 i);
4220 }
4221 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004222 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4223 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4224 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4225 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4226 skip |= LogError(
4227 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4228 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4229 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4230 }
4231 }
4232 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4233 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4234 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4235 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4236 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4237 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4238 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4239 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4240 }
4241 }
4242 }
4243
4244 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4245 pCreateInfo->maxGeometryCount != 1) {
4246 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4247 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4248 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004249 }
4250
4251 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4252 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4253 skip |= LogError(
4254 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4255 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4256 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4257 }
4258
4259 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4260 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4261 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4262 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4263 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4264 }
4265
4266 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4267 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4268 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4269 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4270 if (geometry_type != first_geometry_type) {
4271 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4272 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4273 "pGeometryInfos[0].geometryType.",
4274 i);
4275 }
4276 }
4277 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004278 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4279 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4280 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4281 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4282 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4283 "maxGeometryCount %d.",
4284 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4285 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004286 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004287 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4288 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4289 if (pCreateInfo->deviceAddress != 0) {
4290 skip |=
4291 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4292 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4293 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4294 }
4295 }
sourav parmar83c31b12020-05-06 12:30:54 -07004296 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4297 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4298 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4299 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004300 return skip;
4301}
4302
Jason Macnak5c954952019-07-09 15:46:12 -07004303bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4304 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004305 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004306 bool skip = false;
4307 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004308 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4309 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004310 }
4311 return skip;
4312}
4313
Peter Chen85366392019-05-14 15:20:11 -04004314bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4315 uint32_t createInfoCount,
4316 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4317 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004318 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004319 bool skip = false;
4320
4321 for (uint32_t i = 0; i < createInfoCount; i++) {
4322 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4323 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004324 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004325 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4326 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4327 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4328 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004329 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004330
4331 const auto *pipeline_cache_contol_features =
4332 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4333 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4334 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4335 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4336 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4337 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4338 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4339 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4340 }
4341 }
4342
sourav parmarf4a78252020-04-10 13:04:21 -07004343 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4344 skip |=
4345 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4346 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4347 }
4348 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4349 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4350 skip |=
4351 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4352 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4353 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4354 }
4355 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4356 if (pCreateInfos[i].basePipelineIndex != -1) {
4357 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4358 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4359 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4360 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4361 "and pCreateInfos->basePipelineIndex is not -1.");
4362 }
4363 }
4364 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4365 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4366 skip |=
4367 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4368 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4369 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4370 "commands pCreateInfos parameter.");
4371 }
4372 } else {
4373 if (pCreateInfos[i].basePipelineIndex != -1) {
4374 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4375 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4376 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4377 }
4378 }
4379 }
4380 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4381 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4382 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4383 }
4384 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4385 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4386 "vkCreateRayTracingPipelinesNV: flags must not include "
4387 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4388 }
4389 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4390 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4391 "vkCreateRayTracingPipelinesNV: flags must not include "
4392 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4393 }
4394 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4395 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4396 "vkCreateRayTracingPipelinesNV: flags must not include "
4397 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4398 }
4399 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4400 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4401 "vkCreateRayTracingPipelinesNV: flags must not include "
4402 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4403 }
4404 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4405 skip |= LogError(
4406 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4407 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4408 }
4409 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4410 skip |= LogError(
4411 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4412 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4413 }
Peter Chen85366392019-05-14 15:20:11 -04004414 }
4415
4416 return skip;
4417}
4418
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004419bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4420 uint32_t createInfoCount,
4421 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4422 const VkAllocationCallbacks *pAllocator,
4423 VkPipeline *pPipelines) const {
4424 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004425 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4426 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4427 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4428 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4429 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004430 for (uint32_t i = 0; i < createInfoCount; i++) {
4431 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4432 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4433 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4434 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4435 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4436 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4437 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4438 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004439 const auto *pipeline_cache_contol_features =
4440 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4441 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4442 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4443 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4444 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4445 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4446 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4447 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4448 }
4449 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004450 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4451 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4452 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4453 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4454 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4455 }
4456 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4457 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4458 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4459 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4460 }
4461 }
4462
sourav parmarf4a78252020-04-10 13:04:21 -07004463 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4464 skip |=
4465 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4466 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4467 }
4468 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4469 if (pCreateInfos[i].pLibraryInterface == NULL)
4470 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4471 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4472 }
4473 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4474 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4475 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4476 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4477 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4478 skip |= LogError(
4479 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4480 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4481 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4482 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4483 "must not be VK_SHADER_UNUSED_KHR");
4484 }
4485 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4486 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4487 skip |= LogError(
4488 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4489 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4490 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4491 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4492 "element must not be VK_SHADER_UNUSED_KHR");
4493 }
4494 }
4495 }
4496 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4497 if (pCreateInfos[i].basePipelineIndex != -1) {
4498 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4499 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4500 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4501 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4502 "and pCreateInfos->basePipelineIndex is not -1.");
4503 }
4504 }
4505 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4506 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4507 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4508 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4509 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4510 "commands pCreateInfos parameter %d.",
4511 pCreateInfos[i].basePipelineIndex, createInfoCount);
4512 }
4513 } else {
4514 if (pCreateInfos[i].basePipelineIndex != -1) {
4515 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4516 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4517 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4518 }
4519 }
4520 }
4521 if (pCreateInfos[i].libraries.libraryCount == 0) {
4522 if (pCreateInfos[i].stageCount == 0) {
4523 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4524 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4525 }
4526 if (pCreateInfos[i].groupCount == 0) {
4527 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4528 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4529 }
4530 } else {
4531 if (pCreateInfos[i].pLibraryInterface == NULL) {
4532 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4533 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4534 }
4535 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004536 }
4537
4538 return skip;
4539}
4540
Mike Schuchardt21638df2019-03-16 10:52:02 -07004541#ifdef VK_USE_PLATFORM_WIN32_KHR
4542bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4543 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004544 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004545 bool skip = false;
4546 if (!device_extensions.vk_khr_swapchain)
4547 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4548 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4549 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4550 if (!device_extensions.vk_khr_surface)
4551 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4552 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4553 skip |=
4554 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4555 if (!device_extensions.vk_ext_full_screen_exclusive)
4556 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4557 skip |= validate_struct_type(
4558 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4559 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4560 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4561 if (pSurfaceInfo != NULL) {
4562 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4563 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4564 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4565
4566 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4567 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4568 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4569 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004570 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4571 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004572
4573 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4574 }
4575 return skip;
4576}
4577#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004578
4579bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4580 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004581 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004582 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4583 bool skip = false;
4584 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4585 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4586 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4587 }
4588 return skip;
4589}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004590
4591bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004592 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004593 bool skip = false;
4594
4595 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004596 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4597 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004598 }
4599
4600 return skip;
4601}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004602
4603bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004604 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004605 bool skip = false;
4606
4607 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004608 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4609 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004610 }
4611
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004612 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004613 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004614 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4615 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004616 }
4617
4618 return skip;
4619}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004620
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004621bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4622 uint32_t bindingCount, const VkBuffer *pBuffers,
4623 const VkDeviceSize *pOffsets) const {
4624 bool skip = false;
4625 if (firstBinding > device_limits.maxVertexInputBindings) {
4626 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4627 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4628 device_limits.maxVertexInputBindings);
4629 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4630 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4631 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4632 "maxVertexInputBindings (%u)",
4633 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4634 }
4635
Jeff Bolz165818a2020-05-08 11:19:03 -05004636 for (uint32_t i = 0; i < bindingCount; ++i) {
4637 if (pBuffers[i] == VK_NULL_HANDLE) {
4638 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4639 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4640 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4641 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4642 } else {
4643 if (pOffsets[i] != 0) {
4644 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4645 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4646 }
4647 }
4648 }
4649 }
4650
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004651 return skip;
4652}
4653
Mark Lobodzinski84988402019-09-11 15:27:30 -06004654bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004655 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004656 bool skip = false;
4657 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004658 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4659 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004660 }
4661 return skip;
4662}
4663
4664bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004665 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004666 bool skip = false;
4667 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004668 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4669 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004670 }
4671 return skip;
4672}
Petr Kraus3d720392019-11-13 02:52:39 +01004673
4674bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4675 VkSemaphore semaphore, VkFence fence,
4676 uint32_t *pImageIndex) const {
4677 bool skip = false;
4678
4679 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004680 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4681 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004682 }
4683
4684 return skip;
4685}
4686
4687bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4688 uint32_t *pImageIndex) const {
4689 bool skip = false;
4690
4691 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004692 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4693 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004694 }
4695
4696 return skip;
4697}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004698
4699bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4700 uint32_t firstInstance, VkBuffer counterBuffer,
4701 VkDeviceSize counterBufferOffset,
4702 uint32_t counterOffset, uint32_t vertexStride) const {
4703 bool skip = false;
4704
4705 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004706 skip |= LogError(
4707 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004708 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4709 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4710 }
4711
4712 return skip;
4713}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004714
4715bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4716 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4717 const VkAllocationCallbacks *pAllocator,
4718 VkSamplerYcbcrConversion *pYcbcrConversion,
4719 const char *apiName) const {
4720 bool skip = false;
4721
4722 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004723 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004724 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004725 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4726 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004727 }
4728 return skip;
4729}
4730
4731bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4732 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4733 const VkAllocationCallbacks *pAllocator,
4734 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4735 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4736 "vkCreateSamplerYcbcrConversion");
4737}
4738
4739bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4740 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4741 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4742 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4743 "vkCreateSamplerYcbcrConversionKHR");
4744}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004745
4746bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4747 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4748 bool skip = false;
4749 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4750 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4751
4752 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004753 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4754 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4755 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4756 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4757 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004758 }
4759 return skip;
4760}
sourav parmara96ab1a2020-04-25 16:28:23 -07004761
4762bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4763 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4764 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004765 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4766 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4767 skip |=
4768 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4769 "vkCopyAccelerationStructureToMemoryKHR: the "
4770 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4771 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004772 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4773 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4774 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4775 }
4776 return skip;
4777}
4778
4779bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4780 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4781 bool skip = false;
4782 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4783 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4784 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4785 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4786 }
sourav parmar83c31b12020-05-06 12:30:54 -07004787 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4788 if (pNext_struct) {
4789 skip |= LogError(
4790 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4791 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4792 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4793 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004794 return skip;
4795}
4796
4797bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4798 const char *api_name) const {
4799 bool skip = false;
4800 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4801 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4802 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4803 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4804 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4805 api_name);
4806 }
4807 return skip;
4808}
4809
4810bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4811 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4812 bool skip = false;
4813 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004814 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4815 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4816 skip |= LogError(
4817 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4818 "vkCopyAccelerationStructureKHR(): the "
4819 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4820 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004821 return skip;
4822}
4823
4824bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4825 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4826 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004827 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4828 if (pNext_struct) {
4829 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4830 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4831 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4832 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004833 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4834 return skip;
4835}
4836
4837bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004838 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004839 bool skip = false;
4840 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004841 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004842 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
4843 : "VUID-vkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07004844 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4845 }
4846 return skip;
4847}
4848
4849bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4850 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4851 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004852 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
4853 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4854 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4855 skip |=
4856 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
4857 "vkCopyMemoryToAccelerationStructureKHR() :the "
4858 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4859 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004860 return skip;
4861}
4862bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4863 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4864 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004865 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
4866 return skip;
4867}
4868bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
4869 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4870 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4871 bool skip = false;
4872 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4873 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4874 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4875 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
4876 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4877 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4878 }
4879 return skip;
4880}
4881bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
4882 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4883 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
4884 bool skip = false;
4885 if (dataSize < accelerationStructureCount * stride) {
4886 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
4887 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
4888 "accelerationStructureCount (%d) *stride(%zu).",
4889 dataSize, accelerationStructureCount, stride);
4890 }
4891 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4892 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4893 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4894 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
4895 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4896 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4897 }
4898 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
4899 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4900 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
4901 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4902 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
4903 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4904 stride);
4905 }
4906 }
4907 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
4908 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4909 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
4910 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4911 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
4912 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4913 stride);
4914 }
4915 }
4916 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4917 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4918 skip |=
4919 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
4920 "vkWriteAccelerationStructuresPropertiesKHR: the "
4921 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
4922 "feature must be enabled ");
4923 }
4924 return skip;
4925}
4926bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
4927 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
4928 bool skip = false;
4929 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4930 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
4931 skip |= LogError(device,
4932 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
4933 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
4934 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
4935 "must be enabled to call this function.");
4936 }
4937 return skip;
4938}
4939
4940bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
4941 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4942 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4943 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4944 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4945 uint32_t width, uint32_t height, uint32_t depth) const {
4946 bool skip = false;
4947 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4948 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
4949 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
4950 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4951 }
4952 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4953 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
4954 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
4955 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4956 }
4957 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4958 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
4959 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
4960 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4961 }
4962 // hitShader
4963 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4964 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
4965 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
4966 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4967 }
4968 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4969 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
4970 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
4971 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4972 }
4973 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4974 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
4975 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
4976 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4977 }
4978
4979 // missShader
4980 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4981 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
4982 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
4983 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4984 }
4985 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4986 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
4987 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
4988 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4989 }
4990 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4991 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
4992 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
4993 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4994 }
4995
4996 // raygenShader
4997 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4998 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
4999 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5000 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5001 }
5002 return skip;
5003}
5004
5005bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5006 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5007 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5008 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5009 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5010 VkBuffer buffer, VkDeviceSize offset) const {
5011 bool skip = false;
5012 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5013 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5014 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5015 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5016 "feature must be enabled.");
5017 }
5018 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5019 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5020 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5021 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5022 }
5023 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5024 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5025 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5026 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5027 }
5028 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5029 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5030 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5031 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5032 }
5033 // hitShader
5034 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5035 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5036 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5037 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5038 }
5039 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5040 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5041 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5042 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5043 }
5044 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5045 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5046 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5047 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5048 }
5049
5050 // missShader
5051 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5052 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5053 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5054 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5055 }
5056 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5057 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5058 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5059 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5060 }
5061 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5062 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5063 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5064 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5065 }
5066
5067 // raygenShader
5068 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5069 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5070 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5071 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5072 }
5073 return skip;
5074}
5075bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5076 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5077 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5078 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5079 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5080 uint32_t width, uint32_t height, uint32_t depth) const {
5081 bool skip = false;
5082 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5083 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5084 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5085 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5086 }
5087 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5088 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5089 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5090 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5091 }
5092 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5093 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5094 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5095 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5096 }
5097
5098 // hitShader
5099 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5100 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5101 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5102 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5103 }
5104 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5105 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5106 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5107 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5108 }
5109 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5110 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5111 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5112 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5113 }
5114
5115 // missShader
5116 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5117 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5118 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5119 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5120 }
5121 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5122 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5123 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5124 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5125 }
5126 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5127 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5128 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5129 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5130 }
5131
5132 // raygenShader
5133 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5134 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5135 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
5136 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment .");
5137 }
5138 return skip;
5139}
5140
5141bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5142 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5143 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5144 bool skip = false;
5145 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5146 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5147 skip |= LogError(
5148 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5149 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5150 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5151 }
5152 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5153 if (pNext_struct) {
5154 skip |=
5155 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5156 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5157 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5158 }
5159 return false;
5160}
5161
5162bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5163 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5164 bool skip = false;
5165 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5166 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5167 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5168 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5169 }
5170 return skip;
5171}
5172
5173bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5174 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5175 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5176 bool skip = false;
5177 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5178 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5179 skip |= LogError(
5180 device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5181 "vkBuildAccelerationStructureKHR: The "
5182 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5183 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005184 return skip;
5185}