blob: 21b7fb4fcddeea95bec0ddcb357af4124e958f66 [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 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
sfricke-samsungfd76c342020-05-29 23:13:43 -0700489 // feature dependencies for VK_KHR_multiview
490 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
491 VkBool32 multiview = VK_FALSE;
492 VkBool32 multiviewGeometryShader = VK_FALSE;
493 VkBool32 multiviewTessellationShader = VK_FALSE;
494 if (vulkan_11_features) {
495 multiview = vulkan_11_features->multiview;
496 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
497 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
498 } else if (multiview_features) {
499 multiview = multiview_features->multiview;
500 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
501 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
502 }
503 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
504 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
505 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
506 }
507 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
508 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
509 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
510 }
511
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600512 return skip;
513}
514
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500515bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700516 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700517 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
518 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
519 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700522 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523}
524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700525bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500526 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100527 bool skip = false;
528
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 skip |=
531 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532
533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
534 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
535 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
536 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
538 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
542 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
543 // queueFamilyIndexCount uint32_t values
544 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
546 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
548 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700552 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
553 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
554 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
555 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
556 }
557
558 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
559 skip |=
560 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
561 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
562 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
563 }
564
565 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
566 skip |=
567 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
568 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
569 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
570 }
571
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600572 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
573 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
574 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
575 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
577 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
578 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600579 }
580 }
581
582 return skip;
583}
584
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700585bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500586 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600587 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588
589 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
591 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
592 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
593 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
595 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
596 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 }
598
599 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
600 // queueFamilyIndexCount uint32_t values
601 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
603 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
604 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
605 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600606 }
607 }
608
Dave Houlton413a6782018-05-22 13:01:54 -0600609 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600611 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700612 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600613 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600615
Dave Houlton413a6782018-05-22 13:01:54 -0600616 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700617 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600618 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700619 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620
Dave Houlton130c0212018-01-29 13:39:56 -0700621 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700622 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
623 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(
625 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600626 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
627 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700628 }
629
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600630 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100631 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
632 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700633 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
634 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
635 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600636 }
637
638 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100639 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
640 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700641 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
642 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
643 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
644 ") are not equal.",
645 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100646 }
647
648 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700649 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
650 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
651 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
652 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100653 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
656 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700657 skip |= LogError(
658 device, "VUID-VkImageCreateInfo-imageType-00957",
659 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 }
661 }
662
Dave Houlton130c0212018-01-29 13:39:56 -0700663 // 3D image may have only 1 layer
664 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700665 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
666 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700667 }
668
669 // If multi-sample, validate type, usage, tiling and mip levels.
670 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
671 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600672 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
674 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700675 }
676
677 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
678 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
679 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
680 // At least one of the legal attachment bits must be set
681 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
683 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700684 }
685 // No flags other than the legal attachment bits may be set
686 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
687 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700688 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
689 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700690 }
691 }
692
Jeff Bolzef40fec2018-09-01 22:04:34 -0500693 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500695 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600696 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
697 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500698 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600699 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
701 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
702 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 }
704
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600705 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700706 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
707 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
708 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600709 }
710
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700711 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700712 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
713 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
714 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100715 }
716
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700717 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
718 skip |= LogError(
719 device, "VUID-VkImageCreateInfo-flags-01924",
720 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
721 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
722 }
723
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600724 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
725 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
726 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
727 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
729 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
730 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 }
732
733 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
734 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
735 // Linear tiling is unsupported
736 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700737 skip |= LogError(device, kVUID_PVError_InvalidUsage,
738 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
739 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600740 }
741
742 // Sparse 1D image isn't valid
743 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
745 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 }
747
748 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700749 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
751 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
752 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700756 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
758 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
759 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600760 }
761
762 // Multi-sample 2D image when device doesn't support it
763 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700764 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600765 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
767 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
768 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700769 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700771 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
772 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
773 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700774 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600775 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700776 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
777 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
778 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700779 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600780 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
782 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
783 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600784 }
785 }
786 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500787
Jeff Bolz9af91c52018-09-01 21:53:57 -0500788 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
789 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
791 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
792 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500793 }
794 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
796 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
797 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500798 }
799 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
801 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
802 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500803 }
804 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500805
806 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600807 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
809 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
810 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500811 }
812
Dave Houlton142c4cb2018-10-17 15:04:41 -0600813 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
815 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
816 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
817 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500818 }
819
Dave Houlton142c4cb2018-10-17 15:04:41 -0600820 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
822 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
823 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
824 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500825 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600826 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
828 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
829 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
830 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500831 }
832 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500833
sfricke-samsung8f658d42020-05-03 20:12:24 -0700834 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
835 (FormatHasDepth(pCreateInfo->format) == false)) {
836 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
837 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
838 "format must be a depth or depth/stencil format.");
839 }
840
Andrew Fobel3abeb992020-01-20 16:33:22 -0500841 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
842 if (image_stencil_struct != nullptr) {
843 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
844 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
845 // No flags other than the legal attachment bits may be set
846 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
847 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
849 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
850 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
851 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500852 }
853 }
854
855 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
856 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
857 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
858 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
860 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
861 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
862 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500863 }
864
865 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
866 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 LogError(device, "VUID-VkImageCreateInfo-format-02537",
868 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
869 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
870 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500871 }
872 }
873
874 if (!physical_device_features.shaderStorageImageMultisample &&
875 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
876 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
877 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700878 LogError(device, "VUID-VkImageCreateInfo-format-02538",
879 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
880 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
881 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500882 }
883
884 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
885 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(
887 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500888 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
889 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
890 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
891 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
892 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 skip |= LogError(
894 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500895 "vkCreateImage(): Depth-stencil image in which usage does not include "
896 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
897 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
898 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
899 }
900
901 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
902 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700903 skip |= LogError(
904 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500905 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
906 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
907 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
908 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
909 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(
911 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500912 "vkCreateImage(): Depth-stencil image in which usage does not include "
913 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
914 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
915 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
916 }
917 }
918 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700919
920 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
921 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
922 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
923 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
924 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
925 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700926
927 if (device_extensions.vk_ext_image_drm_format_modifier) {
928 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
929 const auto drm_format_mod_explict =
930 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
931 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
932 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
933 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
934 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
935 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
936 "either VkImageDrmFormatModifierListCreateInfoEXT or "
937 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
938 }
939 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
940 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
941 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
942 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
943 "in the pNext chain");
944 }
945 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200946
947 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
948 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
950 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
951 "imageType must be VK_IMAGE_TYPE_2D.");
952 }
953 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
955 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
956 "samples must be VK_SAMPLE_COUNT_1_BIT.");
957 }
958 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
959 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
960 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
961 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
962 }
963 }
964 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
965 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
966 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
967 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
968 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
969 }
970 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
971 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
972 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
973 "imageType must be VK_IMAGE_TYPE_2D.");
974 }
975 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
976 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
977 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
978 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
979 }
980 if (pCreateInfo->mipLevels != 1) {
981 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
982 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
983 pCreateInfo->mipLevels);
984 }
985 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -0700986
987 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
988 if (swapchain_create_info != nullptr) {
989 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
990 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
991 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
992 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
993 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
994 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
995
996 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
997 // also implicitly forces the check above that extent.depth is 1
998 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
999 string_VkImageType(pCreateInfo->imageType));
1000 }
1001 if (pCreateInfo->mipLevels != 1) {
1002 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1003 pCreateInfo->mipLevels);
1004 }
1005 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1006 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1007 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1008 }
1009 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1010 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1011 base_message, string_VkImageTiling(pCreateInfo->tiling));
1012 }
1013 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1014 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1015 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1016 }
1017 const VkImageCreateFlags valid_flags =
1018 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1019 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1020 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1021 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1022 pCreateInfo->flags);
1023 }
1024 }
1025 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001026 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001027
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001028 return skip;
1029}
1030
Jeff Bolz99e3f632020-03-24 22:59:22 -05001031bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1032 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1033 bool skip = false;
1034
1035 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001036 // Validate feature set if using CUBE_ARRAY
1037 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1038 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1039 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1040 "enabling the imageCubeArray feature.");
1041 }
1042
Jeff Bolz99e3f632020-03-24 22:59:22 -05001043 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1044 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1045 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001046 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001047 pCreateInfo->subresourceRange.layerCount);
1048 }
1049 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001050 skip |= LogError(
1051 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1052 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1053 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001054 }
1055 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001056
1057 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1058 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1059 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1060 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1061 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1062 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1063 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1064 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1065 }
1066 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1067 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1068 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1069 "not an ASTC format.",
1070 string_VkFormat(pCreateInfo->format));
1071 }
1072 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001073
1074 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1075 if (ycbcr_conversion != nullptr) {
1076 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1077 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1078 skip |= LogError(
1079 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1080 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1081 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1082 "r swizzle = %s\n"
1083 "g swizzle = %s\n"
1084 "b swizzle = %s\n"
1085 "a swizzle = %s\n",
1086 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1087 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1088 }
1089 }
1090 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001091 }
1092 return skip;
1093}
1094
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001095bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001096 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001097 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001098
1099 // Note: for numerical correctness
1100 // - float comparisons should expect NaN (comparison always false).
1101 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1102
1103 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001104 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001105 if (v1_f <= 0.0f) return true;
1106
1107 float intpart;
1108 const float fract = modff(v1_f, &intpart);
1109
1110 assert(std::numeric_limits<float>::radix == 2);
1111 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1112 if (intpart >= u32_max_plus1) return false;
1113
1114 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1115 if (v1_u32 < v2_u32)
1116 return true;
1117 else if (v1_u32 == v2_u32 && fract == 0.0f)
1118 return true;
1119 else
1120 return false;
1121 };
1122
1123 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1124 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1125 return (v1_f <= v2_f);
1126 };
1127
1128 // width
1129 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001130 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001131
1132 if (!(viewport.width > 0.0f)) {
1133 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001134 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1135 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001136 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1137 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001138 skip |= LogError(object, "VUID-VkViewport-width-01771",
1139 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1140 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001141 } 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 -07001142 skip |= LogWarning(object, kVUID_PVError_NONE,
1143 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1144 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1145 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001146 }
1147
1148 // height
1149 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001150 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001151 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001152
1153 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1154 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001155 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1156 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001157 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1158 height_healthy = false;
1159
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001160 skip |= LogError(object, "VUID-VkViewport-height-01773",
1161 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1162 ").",
1163 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001164 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1165 height_healthy = false;
1166
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001167 skip |= LogWarning(
1168 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001169 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001170 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001171 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001172 }
1173
1174 // x
1175 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001176 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001177 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001178 skip |= LogError(object, "VUID-VkViewport-x-01774",
1179 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1180 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001181 }
1182
1183 // x + width
1184 if (x_healthy && width_healthy) {
1185 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001186 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001187 skip |= LogError(
1188 object, "VUID-VkViewport-x-01232",
1189 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1190 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1191 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001192 }
1193 }
1194
1195 // y
1196 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001197 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001198 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001199 skip |= LogError(object, "VUID-VkViewport-y-01775",
1200 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1201 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001202 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001203 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001204 skip |= LogError(object, "VUID-VkViewport-y-01776",
1205 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1206 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001207 }
1208
1209 // y + height
1210 if (y_healthy && height_healthy) {
1211 const float boundary = viewport.y + viewport.height;
1212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001213 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001214 skip |= LogError(object, "VUID-VkViewport-y-01233",
1215 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1216 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1217 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001218 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001219 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001220 LogError(object, "VUID-VkViewport-y-01777",
1221 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1222 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1223 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001224 }
1225 }
1226
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001227 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001228 // minDepth
1229 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001230 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001231
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001232 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1233 "[0.0, 1.0] range.",
1234 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001235 }
1236
1237 // maxDepth
1238 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001239 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001240
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001241 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1242 "[0.0, 1.0] range.",
1243 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001244 }
1245 }
1246
1247 return skip;
1248}
1249
Dave Houlton142c4cb2018-10-17 15:04:41 -06001250struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001251 VkShadingRatePaletteEntryNV shadingRate;
1252 uint32_t width;
1253 uint32_t height;
1254};
1255
1256// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001257static SampleOrderInfo sampleOrderInfos[] = {
1258 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1259 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1260 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1261 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1262 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1263 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001264};
1265
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001266bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001267 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001268
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001269 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001270 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001271 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001272 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001273 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001274 break;
1275 }
1276 }
1277
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001278 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001279 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1280 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1281 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001282 return skip;
1283 }
1284
Dave Houlton142c4cb2018-10-17 15:04:41 -06001285 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001286 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001287 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1288 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1289 ") must "
1290 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1291 "is set in framebufferNoAttachmentsSampleCounts.",
1292 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001293 }
1294
Jeff Bolz9af91c52018-09-01 21:53:57 -05001295 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1297 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1298 ") must "
1299 "be equal to the product of sampleCount (=%" PRIu32
1300 "), the fragment width for shadingRate "
1301 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1302 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001303 }
1304
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001305 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001306 skip |= LogError(
1307 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001308 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1309 ") must "
1310 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001311 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001312 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001313
1314 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001315 // the first width*height*sampleCount bits to all be set. Note: There is no
1316 // guarantee that 64 bits is enough, but practically it's unlikely for an
1317 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001318 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001319 uint64_t sampleLocationsMask = 0;
1320 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1321 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1322 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001323 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1324 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001325 }
1326 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1328 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001329 }
1330 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001331 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1332 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001333 }
1334 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1335 sampleLocationsMask |= 1ULL << idx;
1336 }
1337
1338 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1339 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001340 skip |= LogError(
1341 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001342 "The array pSampleLocations must contain exactly one entry for "
1343 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001344 }
1345
1346 return skip;
1347}
1348
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001349bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1350 uint32_t createInfoCount,
1351 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1352 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001353 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001354 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001355
1356 if (pCreateInfos != nullptr) {
1357 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001358 bool has_dynamic_viewport = false;
1359 bool has_dynamic_scissor = false;
1360 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001361 bool has_dynamic_depth_bias = false;
1362 bool has_dynamic_blend_constant = false;
1363 bool has_dynamic_depth_bounds = false;
1364 bool has_dynamic_stencil_compare = false;
1365 bool has_dynamic_stencil_write = false;
1366 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001367 bool has_dynamic_viewport_w_scaling_nv = false;
1368 bool has_dynamic_discard_rectangle_ext = false;
1369 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001370 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001371 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001372 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001373 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001374 bool has_dynamic_cull_mode = false;
1375 bool has_dynamic_front_face = false;
1376 bool has_dynamic_primitive_topology = false;
1377 bool has_dynamic_viewport_with_count = false;
1378 bool has_dynamic_scissor_with_count = false;
1379 bool has_dynamic_vertex_input_binding_stride = false;
1380 bool has_dynamic_depth_test_enable = false;
1381 bool has_dynamic_depth_write_enable = false;
1382 bool has_dynamic_depth_compare_op = false;
1383 bool has_dynamic_depth_bounds_test_enable = false;
1384 bool has_dynamic_stencil_test_enable = false;
1385 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001386 if (pCreateInfos[i].pDynamicState != nullptr) {
1387 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1388 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1389 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001390 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1391 if (has_dynamic_viewport == true) {
1392 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1393 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1394 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1395 i);
1396 }
1397 has_dynamic_viewport = true;
1398 }
1399 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1400 if (has_dynamic_scissor == true) {
1401 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1402 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1403 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1404 i);
1405 }
1406 has_dynamic_scissor = true;
1407 }
1408 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1409 if (has_dynamic_line_width == true) {
1410 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1411 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1412 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1413 i);
1414 }
1415 has_dynamic_line_width = true;
1416 }
1417 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1418 if (has_dynamic_depth_bias == true) {
1419 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1420 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1421 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1422 i);
1423 }
1424 has_dynamic_depth_bias = true;
1425 }
1426 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1427 if (has_dynamic_blend_constant == true) {
1428 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1429 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1430 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1431 i);
1432 }
1433 has_dynamic_blend_constant = true;
1434 }
1435 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1436 if (has_dynamic_depth_bounds == true) {
1437 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1438 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1439 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1440 i);
1441 }
1442 has_dynamic_depth_bounds = true;
1443 }
1444 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1445 if (has_dynamic_stencil_compare == true) {
1446 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1447 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1448 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1449 i);
1450 }
1451 has_dynamic_stencil_compare = true;
1452 }
1453 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1454 if (has_dynamic_stencil_write == true) {
1455 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1456 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1457 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1458 i);
1459 }
1460 has_dynamic_stencil_write = true;
1461 }
1462 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1463 if (has_dynamic_stencil_reference == true) {
1464 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1465 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1466 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1467 i);
1468 }
1469 has_dynamic_stencil_reference = true;
1470 }
1471 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1472 if (has_dynamic_viewport_w_scaling_nv == true) {
1473 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1474 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1475 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1476 i);
1477 }
1478 has_dynamic_viewport_w_scaling_nv = true;
1479 }
1480 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1481 if (has_dynamic_discard_rectangle_ext == true) {
1482 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1483 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1484 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1485 i);
1486 }
1487 has_dynamic_discard_rectangle_ext = true;
1488 }
1489 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1490 if (has_dynamic_sample_locations_ext == true) {
1491 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1492 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1493 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1494 i);
1495 }
1496 has_dynamic_sample_locations_ext = true;
1497 }
1498 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1499 if (has_dynamic_exclusive_scissor_nv == true) {
1500 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1501 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1502 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1503 i);
1504 }
1505 has_dynamic_exclusive_scissor_nv = true;
1506 }
1507 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1508 if (has_dynamic_shading_rate_palette_nv == true) {
1509 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1510 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1511 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1512 i);
1513 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001514 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001515 }
1516 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1517 if (has_dynamic_viewport_course_sample_order_nv == true) {
1518 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1519 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1520 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1521 i);
1522 }
1523 has_dynamic_viewport_course_sample_order_nv = true;
1524 }
1525 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1526 if (has_dynamic_line_stipple == true) {
1527 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1528 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1529 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1530 i);
1531 }
1532 has_dynamic_line_stipple = true;
1533 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001534 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1535 if (has_dynamic_cull_mode) {
1536 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1537 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1538 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1539 i);
1540 }
1541 has_dynamic_cull_mode = true;
1542 }
1543 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1544 if (has_dynamic_front_face) {
1545 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1546 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1547 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1548 i);
1549 }
1550 has_dynamic_front_face = true;
1551 }
1552 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1553 if (has_dynamic_primitive_topology) {
1554 skip |= LogError(
1555 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1556 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1557 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1558 i);
1559 }
1560 has_dynamic_primitive_topology = true;
1561 }
1562 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1563 if (has_dynamic_viewport_with_count) {
1564 skip |= LogError(
1565 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1566 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1567 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1568 i);
1569 }
1570 has_dynamic_viewport_with_count = true;
1571 }
1572 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1573 if (has_dynamic_scissor_with_count) {
1574 skip |= LogError(
1575 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1576 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1577 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1578 i);
1579 }
1580 has_dynamic_scissor_with_count = true;
1581 }
1582 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1583 if (has_dynamic_vertex_input_binding_stride) {
1584 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1585 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1586 "listed twice in the "
1587 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1588 i);
1589 }
1590 has_dynamic_vertex_input_binding_stride = true;
1591 }
1592 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1593 if (has_dynamic_depth_test_enable) {
1594 skip |= LogError(
1595 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1596 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1597 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1598 i);
1599 }
1600 has_dynamic_depth_test_enable = true;
1601 }
1602 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1603 if (has_dynamic_depth_write_enable) {
1604 skip |= LogError(
1605 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1606 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1607 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1608 i);
1609 }
1610 has_dynamic_depth_write_enable = true;
1611 }
1612 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1613 if (has_dynamic_depth_compare_op) {
1614 skip |=
1615 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1616 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1617 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1618 i);
1619 }
1620 has_dynamic_depth_compare_op = true;
1621 }
1622 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1623 if (has_dynamic_depth_bounds_test_enable) {
1624 skip |= LogError(
1625 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1626 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1627 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1628 i);
1629 }
1630 has_dynamic_depth_bounds_test_enable = true;
1631 }
1632 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1633 if (has_dynamic_stencil_test_enable) {
1634 skip |= LogError(
1635 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1636 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1637 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1638 i);
1639 }
1640 has_dynamic_stencil_test_enable = true;
1641 }
1642 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1643 if (has_dynamic_stencil_op) {
1644 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1645 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1646 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1647 i);
1648 }
1649 has_dynamic_stencil_op = true;
1650 }
Petr Kraus299ba622017-11-24 03:09:03 +01001651 }
1652 }
1653
Peter Chen85366392019-05-14 15:20:11 -04001654 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1655 if ((feedback_struct != nullptr) &&
1656 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001657 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1658 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1659 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1660 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1661 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001662 }
1663
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001664 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001665
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001666 // Collect active stages and other information
1667 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001668 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001669 bool has_eval = false;
1670 bool has_control = false;
1671 if (pCreateInfos[i].pStages != nullptr) {
1672 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1673 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1674
1675 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1676 has_control = true;
1677 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1678 has_eval = true;
1679 }
1680
1681 skip |= validate_string(
1682 "vkCreateGraphicsPipelines",
1683 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1684 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1685 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001686 }
1687
1688 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1689 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1690 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1691 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1692 pCreateInfos[i].pTessellationState,
1693 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1694 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1695
1696 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1697 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1698
1699 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1700 "VkPipelineTessellationDomainOriginStateCreateInfo",
1701 pCreateInfos[i].pTessellationState->pNext,
1702 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1703 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001704 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1705 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001706
1707 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1708 pCreateInfos[i].pTessellationState->flags,
1709 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1710 }
1711
1712 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1713 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1714 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1715 pCreateInfos[i].pInputAssemblyState,
1716 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1717 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1718
1719 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1720 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001721 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001722
1723 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1724 pCreateInfos[i].pInputAssemblyState->flags,
1725 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1726
1727 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1728 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1729 pCreateInfos[i].pInputAssemblyState->topology,
1730 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1731
1732 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1733 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1734 }
1735
1736 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001737 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001738
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001739 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001740 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1741 "vkCreateGraphicsPipelines: pararameter "
1742 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1743 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001744 }
1745
1746 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1747 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1748 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1749 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1750 pCreateInfos[i].pVertexInputState->pNext, 1,
1751 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001752 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1753 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001754 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1755 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001756 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001757 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1758 skip |=
1759 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1760 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1761 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1762 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1763 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1764
1765 skip |= validate_array(
1766 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1767 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1768 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1769 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1770
1771 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1772 for (uint32_t vertexBindingDescriptionIndex = 0;
1773 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1774 ++vertexBindingDescriptionIndex) {
1775 skip |= validate_ranged_enum(
1776 "vkCreateGraphicsPipelines",
1777 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1778 AllVkVertexInputRateEnums,
1779 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1780 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1781 }
1782 }
1783
1784 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1785 for (uint32_t vertexAttributeDescriptionIndex = 0;
1786 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1787 ++vertexAttributeDescriptionIndex) {
1788 skip |= validate_ranged_enum(
1789 "vkCreateGraphicsPipelines",
1790 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1791 AllVkFormatEnums,
1792 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1793 "VUID-VkVertexInputAttributeDescription-format-parameter");
1794 }
1795 }
1796
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001797 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001798 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1799 "vkCreateGraphicsPipelines: pararameter "
1800 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1801 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1802 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001803 }
1804
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001805 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001806 skip |=
1807 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1808 "vkCreateGraphicsPipelines: pararameter "
1809 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1810 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1811 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001812 }
1813
1814 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001815 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1816 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001817 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1818 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001819 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1820 "vkCreateGraphicsPipelines: parameter "
1821 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1822 "(%" PRIu32 ") is not distinct.",
1823 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001824 }
1825 vertex_bindings.insert(vertex_bind_desc.binding);
1826
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001827 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001828 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1829 "vkCreateGraphicsPipelines: parameter "
1830 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1831 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1832 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001833 }
1834
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001835 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001836 skip |=
1837 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1838 "vkCreateGraphicsPipelines: parameter "
1839 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1840 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1841 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001842 }
1843 }
1844
Peter Kohautc7d9d392018-07-15 00:34:07 +02001845 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001846 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1847 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001848 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1849 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001850 skip |= LogError(
1851 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001852 "vkCreateGraphicsPipelines: parameter "
1853 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1854 i, d, vertex_attrib_desc.location);
1855 }
1856 attribute_locations.insert(vertex_attrib_desc.location);
1857
1858 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1859 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001860 skip |= LogError(
1861 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001862 "vkCreateGraphicsPipelines: parameter "
1863 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1864 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1865 i, d, vertex_attrib_desc.binding, i);
1866 }
1867
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001868 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001869 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1870 "vkCreateGraphicsPipelines: parameter "
1871 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1872 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1873 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001874 }
1875
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001876 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1878 "vkCreateGraphicsPipelines: parameter "
1879 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1880 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1881 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001882 }
1883
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001884 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001885 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1886 "vkCreateGraphicsPipelines: parameter "
1887 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1888 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1889 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001890 }
1891 }
1892 }
1893
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001894 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1895 if (has_control && has_eval) {
1896 if (pCreateInfos[i].pTessellationState == nullptr) {
1897 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1898 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1899 "shader stage and a tessellation evaluation shader stage, "
1900 "pCreateInfos[%d].pTessellationState must not be NULL.",
1901 i, i);
1902 } else {
1903 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1904 skip |= validate_struct_pnext(
1905 "vkCreateGraphicsPipelines",
1906 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1907 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1908 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1909 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001910
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001911 skip |= validate_reserved_flags(
1912 "vkCreateGraphicsPipelines",
1913 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1914 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001915
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001916 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1917 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1918 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1919 "vkCreateGraphicsPipelines: invalid parameter "
1920 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1921 "should be >0 and <=%u.",
1922 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1923 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001924 }
1925 }
1926 }
1927
1928 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1929 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1930 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1931 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1933 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1934 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1935 "].pViewportState (=NULL) is not a valid pointer.",
1936 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001937 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001938 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1939
1940 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1942 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1943 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1944 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001945 }
1946
Petr Krausa6103552017-11-16 21:21:58 +01001947 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1948 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001949 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1950 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001951 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1952 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001953 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001954 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001955 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001956 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001957 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001958 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1959 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001960 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001961 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1962 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001963
1964 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001965 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001966 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001967 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968
Dave Houlton142c4cb2018-10-17 15:04:41 -06001969 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1970 pCreateInfos[i].pViewportState->pNext);
1971 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1972 pCreateInfos[i].pViewportState->pNext);
1973 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1974 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001975 const auto vp_swizzle_struct =
1976 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001977 const auto vp_w_scaling_struct =
1978 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001979
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001980 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001981 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001982 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1983 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1984 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1985 ") is not 1.",
1986 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001987 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988
Petr Krausa6103552017-11-16 21:21:58 +01001989 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001990 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1991 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1992 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1993 ") is not 1.",
1994 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001995 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001996
Dave Houlton142c4cb2018-10-17 15:04:41 -06001997 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1998 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001999 skip |= LogError(
2000 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2001 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2002 "disabled, but pCreateInfos[%" PRIu32
2003 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2004 ") is not 1.",
2005 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002006 }
2007
Jeff Bolz9af91c52018-09-01 21:53:57 -05002008 if (shading_rate_image_struct &&
2009 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002010 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2011 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2012 "disabled, but pCreateInfos[%" PRIu32
2013 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2014 ") is neither 0 nor 1.",
2015 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002016 }
2017
Petr Krausa6103552017-11-16 21:21:58 +01002018 } else { // multiViewport enabled
2019 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002020 if (!has_dynamic_viewport_with_count) {
2021 skip |= LogError(
2022 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2023 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2024 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002025 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002026 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2027 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2028 "].pViewportState->viewportCount (=%" PRIu32
2029 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2030 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002031 } else if (has_dynamic_viewport_with_count) {
2032 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2033 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2034 "].pViewportState->viewportCount (=%" PRIu32
2035 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2036 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002037 }
Petr Krausa6103552017-11-16 21:21:58 +01002038
2039 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002040 if (!has_dynamic_scissor_with_count) {
2041 skip |= LogError(
2042 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2043 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2044 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002045 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002046 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2047 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2048 "].pViewportState->scissorCount (=%" PRIu32
2049 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2050 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002051 } else if (has_dynamic_scissor_with_count) {
2052 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2053 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2054 "].pViewportState->scissorCount (=%" PRIu32
2055 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2056 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 }
2058 }
2059
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002060 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002061 skip |=
2062 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2063 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2064 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2065 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002066 }
2067
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002068 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002069 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2070 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2071 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2072 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2073 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002074 }
2075
Piers Daniell39842ee2020-07-10 16:42:33 -06002076 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2077 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002078 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2079 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2080 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2081 "].pViewportState->viewportCount (=%" PRIu32 ").",
2082 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002083 }
2084
Dave Houlton142c4cb2018-10-17 15:04:41 -06002085 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002086 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002087 skip |=
2088 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2089 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2090 ") must be zero or identical to pCreateInfos[%" PRIu32
2091 "].pViewportState->viewportCount (=%" PRIu32 ").",
2092 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002093 }
2094
Dave Houlton142c4cb2018-10-17 15:04:41 -06002095 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002096 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002097 skip |= LogError(
2098 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002099 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2100 "] "
2101 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2102 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2103 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002104 }
2105
Petr Krausa6103552017-11-16 21:21:58 +01002106 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |= LogError(
2108 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002109 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2110 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002111 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2112 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002113 }
2114
2115 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002116 skip |= LogError(
2117 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002118 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2119 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002120 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2121 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002122 }
2123
Jeff Bolz3e71f782018-08-29 23:15:45 -05002124 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002125 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2126 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2127 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002128 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002129 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2130 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2131 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2132 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002133 }
2134
Jeff Bolz9af91c52018-09-01 21:53:57 -05002135 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002136 shading_rate_image_struct->viewportCount > 0 &&
2137 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002138 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002139 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002140 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002141 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2142 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002143 i, i);
2144 }
2145
Chris Mayer328d8212018-12-11 14:16:18 +01002146 if (vp_swizzle_struct) {
2147 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002148 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2149 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2150 " does "
2151 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2152 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002153 }
2154 }
2155
Petr Krausb3fcdb42018-01-09 22:09:09 +01002156 // validate the VkViewports
2157 if (!has_dynamic_viewport && viewport_state.pViewports) {
2158 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2159 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002160 const char *fn_name = "vkCreateGraphicsPipelines";
2161 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2162 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2163 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002164 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002165 }
2166 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002167
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002168 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002169 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2170 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2171 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2172 "VK_NV_clip_space_w_scaling extension is not enabled.",
2173 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002174 }
2175
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002176 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002177 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2178 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2179 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2180 "VK_EXT_discard_rectangles extension is not enabled.",
2181 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002182 }
2183
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002185 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2186 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2187 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2188 "VK_EXT_sample_locations extension is not enabled.",
2189 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002190 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002191
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002192 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002193 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2194 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2195 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2196 "VK_NV_scissor_exclusive extension is not enabled.",
2197 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002198 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002199
2200 if (coarse_sample_order_struct &&
2201 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2202 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002203 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2204 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2205 "] "
2206 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2207 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2208 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002209 }
2210
2211 if (coarse_sample_order_struct) {
2212 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002214 }
2215 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002216
2217 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2218 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002219 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2220 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2221 "] "
2222 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2223 ") "
2224 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2225 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002226 }
2227 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002228 skip |= LogError(
2229 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002230 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2231 "] "
2232 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2233 i);
2234 }
2235 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002236 }
2237
2238 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2240 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2241 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2242 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002244 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
2245 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2246 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002247 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002248 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002249 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002250 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002251 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002252 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002253 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002254 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2255 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256
2257 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002258 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002260 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261
2262 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002263 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002264 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2265 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2266
2267 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002268 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2270 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002271 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002272 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002274 skip |= validate_flags(
2275 "vkCreateGraphicsPipelines",
2276 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2277 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002278 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002279
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002280 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2283 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2284
2285 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002286 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002287 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2288 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2289
2290 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002291 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2292 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2293 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2294 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002295 }
John Zulauf7acac592017-11-06 11:15:53 -07002296 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002297 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002298 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2299 "vkCreateGraphicsPipelines(): parameter "
2300 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2301 i);
John Zulauf7acac592017-11-06 11:15:53 -07002302 }
2303 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2304 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2305 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002306 skip |= LogError(
2307 device,
2308
Dave Houlton413a6782018-05-22 13:01:54 -06002309 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002310 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002311 }
2312 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002313
2314 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2315 pCreateInfos[i].pRasterizationState->pNext);
2316
2317 if (line_state) {
2318 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2319 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2320 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2321 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002322 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2323 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2324 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2325 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002326 }
2327 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2328 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2330 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2331 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2332 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002333 }
2334 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2335 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002336 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2337 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2338 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2339 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002340 }
2341 }
2342 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2343 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2344 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2346 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2347 "range [1,256].",
2348 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002349 }
2350 }
2351 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002352 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002353 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2354 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002355 skip |=
2356 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2357 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2358 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2359 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002360 }
2361 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2362 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002363 skip |=
2364 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2365 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2366 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2367 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002368 }
2369 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2370 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 skip |=
2372 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2373 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2374 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2375 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002376 }
2377 if (line_state->stippledLineEnable) {
2378 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2379 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002380 skip |=
2381 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2382 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2383 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2384 "stippledRectangularLines feature.",
2385 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002386 }
2387 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2388 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002389 skip |=
2390 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2391 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2392 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2393 "stippledBresenhamLines feature.",
2394 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002395 }
2396 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2397 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002398 skip |=
2399 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2400 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2401 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2402 "stippledSmoothLines feature.",
2403 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002404 }
2405 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2406 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002407 skip |=
2408 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2409 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2410 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2411 "stippledRectangularLines and strictLines features.",
2412 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002413 }
2414 }
2415 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002416 }
2417
Petr Krause91f7a12017-12-14 20:57:36 +01002418 bool uses_color_attachment = false;
2419 bool uses_depthstencil_attachment = false;
2420 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002421 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002422 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2423 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002424 const auto &subpasses_uses = subpasses_uses_it->second;
2425 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2426 uses_color_attachment = true;
2427 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2428 uses_depthstencil_attachment = true;
2429 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002430 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002431 }
2432
2433 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002434 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002435 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002437 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002438 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002439
2440 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002441 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002442 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002443 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444
2445 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002446 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002447 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2448 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2449
2450 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002451 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002452 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2453 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2454
2455 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002456 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002457 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2458 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002459 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002460
2461 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002462 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002463 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2464 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2465
2466 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2469 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2470
2471 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002472 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2474 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002475 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476
2477 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002478 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2480 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002481 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002482
2483 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002484 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2486 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002487 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488
2489 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002490 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2492 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002493 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494
2495 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002496 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2498 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002499 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500
2501 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002502 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002503 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2504 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002505 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506
2507 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002508 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2510 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002511 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002512
2513 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002514 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2516 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002517 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518
2519 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002520 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2521 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2522 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2523 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002524 }
2525 }
2526
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002527 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2528 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2529
Petr Krause91f7a12017-12-14 20:57:36 +01002530 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002531 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2532 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2533 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2534 pCreateInfos[i].pColorBlendState,
2535 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2536 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2537
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002539 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002540 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2541 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2542 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002543 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002544 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2545 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002546
2547 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002548 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002550 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002551
2552 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002553 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2555 pCreateInfos[i].pColorBlendState->logicOpEnable);
2556
2557 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002558 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002559 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2560 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002561 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002562 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563
2564 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2565 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2566 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002567 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2569 ParameterName::IndexVector{i, attachmentIndex}),
2570 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2571
2572 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002573 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002574 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2575 ParameterName::IndexVector{i, attachmentIndex}),
2576 "VkBlendFactor", AllVkBlendFactorEnums,
2577 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002578 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002579
2580 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002581 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002582 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2583 ParameterName::IndexVector{i, attachmentIndex}),
2584 "VkBlendFactor", AllVkBlendFactorEnums,
2585 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002586 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002587
2588 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002589 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2591 ParameterName::IndexVector{i, attachmentIndex}),
2592 "VkBlendOp", AllVkBlendOpEnums,
2593 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002594 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002595
2596 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002597 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002598 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2599 ParameterName::IndexVector{i, attachmentIndex}),
2600 "VkBlendFactor", AllVkBlendFactorEnums,
2601 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002602 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002603
2604 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002605 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2607 ParameterName::IndexVector{i, attachmentIndex}),
2608 "VkBlendFactor", AllVkBlendFactorEnums,
2609 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002610 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611
2612 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002613 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2615 ParameterName::IndexVector{i, attachmentIndex}),
2616 "VkBlendOp", AllVkBlendOpEnums,
2617 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002618 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002619
2620 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002621 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2623 ParameterName::IndexVector{i, attachmentIndex}),
2624 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2625 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002626 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002627 }
2628 }
2629
2630 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002631 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2632 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2633 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2634 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002635 }
2636
2637 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2638 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2639 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002640 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002641 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002642 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2643 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644 }
2645 }
2646 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647
Petr Kraus9752aae2017-11-24 03:05:50 +01002648 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2649 if (pCreateInfos[i].basePipelineIndex != -1) {
2650 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002651 skip |=
2652 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002653 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002654 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002655 "and pCreateInfos->basePipelineIndex is not -1.",
2656 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002657 }
2658 }
2659
Petr Kraus9752aae2017-11-24 03:05:50 +01002660 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2661 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002662 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002663 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002664 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002665 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2666 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002668 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002669 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002670 skip |=
2671 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2672 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2673 "index into the pCreateInfos array, of size %d.",
2674 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002675 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 }
2677 }
2678
sfricke-samsung898cf222020-05-15 23:10:19 -07002679 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2680 skip |= LogError(
2681 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2682 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2683 i);
2684 }
2685
Petr Kraus9752aae2017-11-24 03:05:50 +01002686 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002687 if (!device_extensions.vk_nv_fill_rectangle) {
2688 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2689 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002690 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2691 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2692 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2693 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002694 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2695 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002696 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2697 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002698 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2699 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2700 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002701 }
2702 } else {
2703 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2704 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2705 (physical_device_features.fillModeNonSolid == false)) {
2706 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002707 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2708 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002709 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2710 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2711 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002712 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713 }
Petr Kraus299ba622017-11-24 03:09:03 +01002714
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002715 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002716 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002717 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2718 "The line width state is static (pCreateInfos[%" PRIu32
2719 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2720 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2721 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2722 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002723 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002724 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002725 }
2726 }
2727
2728 return skip;
2729}
2730
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002731bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2732 uint32_t createInfoCount,
2733 const VkComputePipelineCreateInfo *pCreateInfos,
2734 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002735 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002736 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002737 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002738 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002740 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002741 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2742 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002743 skip |=
2744 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2745 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2746 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2747 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002748 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002749
2750 // Make sure compute stage is selected
2751 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2753 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2754 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002755 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 return skip;
2758}
2759
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002760bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002761 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002762 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763
2764 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002765 const auto &features = physical_device_features;
2766 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002767
John Zulauf71968502017-10-26 13:51:15 -06002768 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2769 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002770 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2771 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2772 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2773 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002774 }
2775
2776 // Anistropy cannot be enabled in sampler unless enabled as a feature
2777 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002778 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2779 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2780 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002781 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002782 }
John Zulauf71968502017-10-26 13:51:15 -06002783
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002784 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2785 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002786 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2787 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2788 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2789 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002790 }
2791 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002792 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2793 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2794 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2795 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002796 }
2797 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2799 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2800 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2801 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002802 }
2803 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2804 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2805 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2806 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2808 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2809 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2810 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2811 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2812 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002813 }
2814 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002815 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2816 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2817 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002818 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002819 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002820 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2821 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2822 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002823 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002824 }
2825
2826 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2827 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002828 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2829 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002830 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2831 if (sampler_reduction != nullptr) {
2832 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2833 skip |= LogError(
2834 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2835 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2836 }
2837 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002838 }
2839
2840 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2841 // valid VkBorderColor value
2842 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2843 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2844 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002845 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2846 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002847 }
2848
2849 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2850 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002851 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2853 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2854 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002855 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002856 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2857 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2858 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 }
John Zulauf275805c2017-10-26 15:34:49 -06002860
2861 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002862 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002863 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2864 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002865 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2866 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2867 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002868 }
2869 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002870
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002871 // Check for valid Lod range
2872 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002873 skip |=
2874 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2875 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002876 }
2877
2878 // Check mipLodBias to device limit
2879 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002880 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2881 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2882 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002883 }
2884
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002885 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2886 if (sampler_conversion != nullptr) {
2887 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2888 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2889 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2890 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002891 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002892 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002893 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2894 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2895 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2896 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2897 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2898 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2899 }
2900 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002901
2902 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2903 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2904 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2905 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2906 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2907 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2908 }
2909 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2910 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2911 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2912 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2913 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2914 }
2915 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2916 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2917 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2918 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2919 pCreateInfo->minLod, pCreateInfo->maxLod);
2920 }
2921 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2922 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2923 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2924 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2925 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2926 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2927 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2928 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2929 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2930 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2931 }
2932 if (pCreateInfo->anisotropyEnable) {
2933 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2934 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2935 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2936 }
2937 if (pCreateInfo->compareEnable) {
2938 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2939 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2940 "pCreateInfo->compareEnable must be VK_FALSE");
2941 }
2942 if (pCreateInfo->unnormalizedCoordinates) {
2943 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2944 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2945 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2946 }
2947 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002948 }
2949
Tony-LunarG7337b312020-04-15 16:40:25 -06002950 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2951 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2952 if (!device_extensions.vk_ext_custom_border_color) {
2953 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2954 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2955 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2956 }
2957 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2958 if (!custom_create_info) {
2959 skip |=
2960 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2961 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2962 "struct in pNext chain.\n",
2963 string_VkBorderColor(pCreateInfo->borderColor));
2964 } else {
2965 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2966 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2967 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2968 !FormatIsSampledFloat(custom_create_info->format)))) {
2969 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2970 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2971 "whose type does not match\n",
2972 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2973 ;
2974 }
2975 }
2976 }
2977
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002978 return skip;
2979}
2980
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002981bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2982 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2983 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002984 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986
2987 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2988 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2989 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2990 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002991 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2992 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2993 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2994 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2995 ++descriptor_index) {
2996 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002997 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002998 "vkCreateDescriptorSetLayout: required parameter "
2999 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3000 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003001 }
3002 }
3003 }
3004
3005 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3006 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3007 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003008 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3009 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3010 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3011 "values.",
3012 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003013 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003014
3015 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3016 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3017 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3018 skip |=
3019 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3020 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3021 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3022 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3023 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3024 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025 }
3026 }
3027 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028 return skip;
3029}
3030
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003031bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3032 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003033 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003034 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3035 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3036 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003037 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3038 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003039}
3040
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003041bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3042 const VkWriteDescriptorSet *pDescriptorWrites,
3043 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003045
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003046 if (pDescriptorWrites != NULL) {
3047 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3048 // descriptorCount must be greater than 0
3049 if (pDescriptorWrites[i].descriptorCount == 0) {
3050 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3052 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 }
3054
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003055 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3056 if (validateDstSet) {
3057 // dstSet must be a valid VkDescriptorSet handle
3058 skip |= validate_required_handle(vkCallingFunction,
3059 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3060 pDescriptorWrites[i].dstSet);
3061 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062
3063 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3064 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3065 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3066 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3067 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3068 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3069 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003070 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3071 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003073 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3074 "%s(): if pDescriptorWrites[%d].descriptorType is "
3075 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3076 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3077 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3078 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003079 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3080 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003081 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3082 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3084 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003085 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3087 ParameterName::IndexVector{i, descriptor_index}),
3088 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003089 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090 }
3091 }
3092 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3093 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3094 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3095 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3096 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3097 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3098 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003099 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003101 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3102 "%s(): if pDescriptorWrites[%d].descriptorType is "
3103 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3104 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3105 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3106 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003108 const auto *robustness2_features =
3109 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3110 if (robustness2_features && robustness2_features->nullDescriptor) {
3111 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
3112 ++descriptorIndex) {
3113 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
3114 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
3115 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
3116 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3117 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
3118 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
3119 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
3120 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
3121 }
3122 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003123 }
3124 }
3125 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3126 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003127 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128 }
3129
3130 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3131 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003132 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3134 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3135 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003136 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003137 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3138 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3139 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3140 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003141 }
3142 }
3143 }
3144 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3145 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003146 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3148 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3149 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003150 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003151 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3152 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3153 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3154 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155 }
3156 }
3157 }
3158 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003159 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3160 // or VkWriteDescriptorSetInlineUniformBlockEX
3161 if (pDescriptorWrites[i].pNext) {
3162 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003163 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003164 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003165 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003166 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3167 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3168 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3169 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003170 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003171 pDescriptorWrites[i].descriptorCount);
3172 }
3173 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003174 if (pnext_struct) {
3175 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003176 skip |= LogError(
3177 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3178 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3179 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003180 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003181 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003182 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003183 skip |= LogError(
3184 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3185 "%s(): accelerationStructureCount must be greater than 0 .");
3186 }
3187 }
3188 }
3189 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190 }
3191 }
3192 return skip;
3193}
3194
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003195bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3196 const VkWriteDescriptorSet *pDescriptorWrites,
3197 uint32_t descriptorCopyCount,
3198 const VkCopyDescriptorSet *pDescriptorCopies) const {
3199 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3200}
3201
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003202bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003203 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003204 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003205 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3206}
3207
3208bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003209 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003210 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003211 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3212}
3213
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003214bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3215 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003216 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218
3219 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3220 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3221 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003222 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3223 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003224 return skip;
3225}
3226
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003227bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003228 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003229 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003230
3231 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3232 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3234
Petr Krause7bb9e82019-08-11 21:34:43 +02003235 // Implicit VUs
3236 // validate only sType here; pointer has to be validated in core_validation
3237 const bool kNotRequired = false;
3238 const char *kNoVUID = nullptr;
3239 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3240 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3241 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003242
Petr Krause7bb9e82019-08-11 21:34:43 +02003243 if (pInfo) {
3244 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3245 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3246 skip |= validate_struct_pnext(
3247 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3248 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003249 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3250 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003251
Petr Krause7bb9e82019-08-11 21:34:43 +02003252 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253
Petr Krause7bb9e82019-08-11 21:34:43 +02003254 // Explicit VUs
3255 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003256 skip |= LogError(
3257 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003258 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3259 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003260 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003261
3262 if (physical_device_features.inheritedQueries) {
3263 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003264 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003265 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003266 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003267 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003268 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003269 }
3270
3271 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003272 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003273 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003274 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003275 } else { // !pipelineStatisticsQuery
3276 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3277 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003278 }
Petr Kraus139757b2019-08-15 17:19:33 +02003279
3280 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3281 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003282 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003283 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3284 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 skip |= LogError(
3286 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003287 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3288 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3289 }
3290 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003291 }
3292
3293 return skip;
3294}
3295
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003296bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003297 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003299
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003300 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003301 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003302 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3303 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3304 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003305 }
3306 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003307 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3308 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3309 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003310 }
3311 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003312 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003313 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003314 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3315 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3316 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3317 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003318 }
3319 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003320
3321 if (pViewports) {
3322 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3323 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003324 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003325 skip |= manual_PreCallValidateViewport(
3326 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003327 }
3328 }
3329
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330 return skip;
3331}
3332
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003333bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003334 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003335 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003336
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003337 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003339 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3340 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3341 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003342 }
3343 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003344 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3345 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3346 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003347 }
3348 } else { // multiViewport enabled
3349 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003350 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003351 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3352 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3353 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3354 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003355 }
3356 }
3357
Petr Kraus6260f0a2018-02-27 21:15:55 +01003358 if (pScissors) {
3359 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3360 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003361
Petr Kraus6260f0a2018-02-27 21:15:55 +01003362 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003363 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3364 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3365 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003366 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003367
Petr Kraus6260f0a2018-02-27 21:15:55 +01003368 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003369 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3370 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3371 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003372 }
3373
3374 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3375 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003376 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3377 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3378 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3379 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003380 }
3381
3382 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3383 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003384 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3385 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3386 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3387 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003388 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003389 }
3390 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003391
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003392 return skip;
3393}
3394
Jeff Bolz5c801d12019-10-09 10:38:45 -05003395bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003396 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003397
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003398 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003399 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3400 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003401 }
3402
3403 return skip;
3404}
3405
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003406bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003407 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003408 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 if (vertexCount == 0) {
3410 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3411 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003412 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003413 }
3414
3415 if (instanceCount == 0) {
3416 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3417 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003418 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003419 }
3420 return skip;
3421}
3422
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003423bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003424 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003425 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003427 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003428 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3429 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003430 }
3431 return skip;
3432}
3433
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003434bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003435 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003437 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003438 skip |=
3439 LogError(device, kVUID_PVError_DeviceFeature,
3440 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441 }
3442 return skip;
3443}
3444
sfricke-samsungf692b972020-05-02 08:00:45 -07003445bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3446 VkDeviceSize countBufferOffset, bool khr) const {
3447 bool skip = false;
3448 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3449 if (offset & 3) {
3450 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3451 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3452 }
3453
3454 if (countBufferOffset & 3) {
3455 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3456 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3457 countBufferOffset);
3458 }
3459 return skip;
3460}
3461
3462bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3463 VkDeviceSize offset, VkBuffer countBuffer,
3464 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3465 uint32_t stride) const {
3466 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3467}
3468
3469bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3470 VkDeviceSize offset, VkBuffer countBuffer,
3471 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3472 uint32_t stride) const {
3473 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3474}
3475
3476bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3477 VkDeviceSize countBufferOffset, bool khr) const {
3478 bool skip = false;
3479 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3480 if (offset & 3) {
3481 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3482 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3483 }
3484
3485 if (countBufferOffset & 3) {
3486 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3487 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3488 countBufferOffset);
3489 }
3490 return skip;
3491}
3492
3493bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3494 VkDeviceSize offset, VkBuffer countBuffer,
3495 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3496 uint32_t stride) const {
3497 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3498}
3499
3500bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3501 VkDeviceSize offset, VkBuffer countBuffer,
3502 VkDeviceSize countBufferOffset,
3503 uint32_t maxDrawCount, uint32_t stride) const {
3504 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3505}
3506
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003507bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3508 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003509 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003510 bool skip = false;
3511 for (uint32_t rect = 0; rect < rectCount; rect++) {
3512 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003513 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3514 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003515 }
sfricke-samsung10867682020-04-25 02:20:39 -07003516 if (pRects[rect].rect.extent.width == 0) {
3517 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3518 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3519 }
3520 if (pRects[rect].rect.extent.height == 0) {
3521 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3522 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3523 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003524 }
3525 return skip;
3526}
3527
Andrew Fobel3abeb992020-01-20 16:33:22 -05003528bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3529 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3530 VkImageFormatProperties2 *pImageFormatProperties,
3531 const char *apiName) const {
3532 bool skip = false;
3533
3534 if (pImageFormatInfo != nullptr) {
3535 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3536 if (image_stencil_struct != nullptr) {
3537 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3538 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3539 // No flags other than the legal attachment bits may be set
3540 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3541 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003542 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3543 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3544 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3545 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3546 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003547 }
3548 }
3549 }
3550 }
3551
3552 return skip;
3553}
3554
3555bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3556 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3557 VkImageFormatProperties2 *pImageFormatProperties) const {
3558 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3559 "vkGetPhysicalDeviceImageFormatProperties2");
3560}
3561
3562bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3563 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3564 VkImageFormatProperties2 *pImageFormatProperties) const {
3565 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3566 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3567}
3568
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003569bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3570 VkImageLayout srcImageLayout, VkImage dstImage,
3571 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003572 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003573 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003574
Dave Houltonf5217612018-02-02 16:18:52 -07003575 VkImageAspectFlags legal_aspect_flags =
3576 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 -07003577 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003578 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3579 }
3580
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003581 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003582 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003583 skip |= LogError(
3584 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003585 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003586 }
Dave Houltonf5217612018-02-02 16:18:52 -07003587 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003588 skip |= LogError(
3589 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003590 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003591 }
3592 }
3593 return skip;
3594}
3595
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003596bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3597 VkImageLayout srcImageLayout, VkImage dstImage,
3598 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003599 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003600 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601
Dave Houltonf5217612018-02-02 16:18:52 -07003602 VkImageAspectFlags legal_aspect_flags =
3603 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 -07003604 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003605 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3606 }
3607
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003609 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 skip |= LogError(
3611 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003612 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3613 }
Dave Houltonf5217612018-02-02 16:18:52 -07003614 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003615 skip |= LogError(
3616 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003617 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3618 }
3619 }
3620 return skip;
3621}
3622
sfricke-samsung3999ef62020-02-09 17:05:59 -08003623bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3624 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3625 bool skip = false;
3626
3627 if (pRegions != nullptr) {
3628 for (uint32_t i = 0; i < regionCount; i++) {
3629 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003630 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3631 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003632 }
3633 }
3634 }
3635 return skip;
3636}
3637
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003638bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3639 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003640 uint32_t regionCount,
3641 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003642 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003643
Dave Houltonf5217612018-02-02 16:18:52 -07003644 VkImageAspectFlags legal_aspect_flags =
3645 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 -07003646 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003647 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3648 }
3649
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003650 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003651 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003652 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3653 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3654 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003655 }
3656 }
3657 return skip;
3658}
3659
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003660bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3661 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003662 uint32_t regionCount,
3663 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003664 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003665
Dave Houltonf5217612018-02-02 16:18:52 -07003666 VkImageAspectFlags legal_aspect_flags =
3667 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 -07003668 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003669 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3670 }
3671
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003672 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003673 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003674 skip |= LogError(
3675 device, kVUID_PVError_UnrecognizedValue,
3676 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3677 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678 }
3679 }
3680 return skip;
3681}
3682
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003683bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003684 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3685 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003686 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003687
3688 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003689 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3690 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3691 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003692 }
3693
3694 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003695 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3696 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3697 "), must be greater than zero and less than or equal to 65536.",
3698 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003699 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003700 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3701 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3702 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003703 }
3704 return skip;
3705}
3706
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003707bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003708 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003709 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003710
3711 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003712 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3713 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3714 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003715 }
3716
3717 if (size != VK_WHOLE_SIZE) {
3718 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003719 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003720 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3721 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003722 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003723 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3724 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003725 }
3726 }
3727 return skip;
3728}
3729
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003730bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003731 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003732 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003733 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003734
3735 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003736 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3737 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3738 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3739 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003740 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3741 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3742 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003743 }
3744
3745 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3746 // queueFamilyIndexCount uint32_t values
3747 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003748 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3749 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3750 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3751 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003752 }
3753 }
3754
Dave Houlton413a6782018-05-22 13:01:54 -06003755 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003757 }
3758
3759 return skip;
3760}
3761
Jeff Bolz5c801d12019-10-09 10:38:45 -05003762bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003763 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003764
3765 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003766 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3767 if (present_regions) {
3768 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003769 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003770 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3771 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003772 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3773 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3774 "extension swapchainCount is %i. These values must be equal.",
3775 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003776 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003777 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003778 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3779 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003780 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3781 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3782 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003783 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003784 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003785 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003786 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003787 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003788 }
3789 }
3790
3791 return skip;
3792}
3793
3794#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003795bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3796 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3797 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003798 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003799 bool skip = false;
3800
3801 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003802 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3803 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003804 }
3805
3806 return skip;
3807}
3808#endif // VK_USE_PLATFORM_WIN32_KHR
3809
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003810bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003811 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003812 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003813 bool skip = false;
3814
3815 if (pCreateInfo) {
3816 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003817 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3818 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003819 }
3820
3821 if (pCreateInfo->pPoolSizes) {
3822 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3823 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 skip |= LogError(
3825 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003826 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003827 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003828 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3829 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3831 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3832 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3833 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3834 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003835 }
Petr Krausc8655be2017-09-27 18:56:51 +02003836 }
3837 }
3838 }
3839
3840 return skip;
3841}
3842
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003843bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003844 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003845 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003846
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003847 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003848 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3850 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3851 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003852 }
3853
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003854 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003855 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3857 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3858 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003859 }
3860
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003861 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003862 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003863 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3864 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3865 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003866 }
3867
3868 return skip;
3869}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003870
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003871bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003872 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003873 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003874
3875 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003876 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3877 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003878 }
3879 return skip;
3880}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003881
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003882bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3883 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003884 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003885 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003886
3887 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003888 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003889 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003890 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3891 "vkCmdDispatch(): baseGroupX (%" PRIu32
3892 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3893 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003894 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003895 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3896 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3897 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3898 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003899 }
3900
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003901 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003902 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003903 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3904 "vkCmdDispatch(): baseGroupY (%" PRIu32
3905 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3906 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003907 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3909 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3910 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3911 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003912 }
3913
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003914 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003915 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003916 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3917 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3918 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3919 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003920 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003921 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3922 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3923 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3924 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003925 }
3926
3927 return skip;
3928}
3929
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003930bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3931 VkPipelineBindPoint pipelineBindPoint,
3932 VkPipelineLayout layout, uint32_t set,
3933 uint32_t descriptorWriteCount,
3934 const VkWriteDescriptorSet *pDescriptorWrites) const {
3935 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3936}
3937
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003938bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3939 uint32_t firstExclusiveScissor,
3940 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003941 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003942 bool skip = false;
3943
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003944 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003945 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003946 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003947 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3948 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3949 ") is not 0.",
3950 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003951 }
3952 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003953 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003954 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3955 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3956 ") is not 1.",
3957 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003958 }
3959 } else { // multiViewport enabled
3960 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003961 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003962 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3963 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3964 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3965 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003966 }
3967 }
3968
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003969 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003970 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3971 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3972 ") must be less than maxViewports (=%" PRIu32 ").",
3973 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003974 }
3975
3976 if (pExclusiveScissors) {
3977 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3978 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3979
3980 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003981 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3982 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3983 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003984 }
3985
3986 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003987 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3988 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3989 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003990 }
3991
3992 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3993 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003994 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3995 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3996 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3997 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003998 }
3999
4000 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4001 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004002 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4003 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4004 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4005 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004006 }
4007 }
4008 }
4009
4010 return skip;
4011}
4012
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004013bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4014 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004015 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004016 bool skip = false;
4017 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004018 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
4019 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
4020 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004021 } else {
4022 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4023 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004024 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4025 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4026 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4027 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004028 }
4029 }
4030
4031 return skip;
4032}
4033
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004034bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4035 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004036 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004037 bool skip = false;
4038
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004039 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004040 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004041 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004042 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4043 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4044 ") is not 0.",
4045 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004046 }
4047 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004048 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004049 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4050 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4051 ") is not 1.",
4052 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004053 }
4054 }
4055
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004056 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004057 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
4058 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
4059 ") must be less than maxViewports (=%" PRIu32 ").",
4060 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004061 }
4062
4063 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004064 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4066 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4067 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4068 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004069 }
4070
4071 return skip;
4072}
4073
Jeff Bolz5c801d12019-10-09 10:38:45 -05004074bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4075 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4076 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004077 bool skip = false;
4078
Dave Houlton142c4cb2018-10-17 15:04:41 -06004079 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004080 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4081 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4082 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004083 }
4084
4085 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004086 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004087 }
4088
4089 return skip;
4090}
4091
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004092bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004093 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004094 bool skip = false;
4095
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004096 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004097 skip |= LogError(
4098 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004099 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4100 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004101 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004102 }
4103
4104 return skip;
4105}
4106
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004107bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4108 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004109 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004110 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004111 static const int condition_multiples = 0b0011;
4112 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004113 skip |= LogError(
4114 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004115 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004116 }
Lockee1c22882019-06-10 16:02:54 -06004117 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004118 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4119 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4120 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4121 stride);
Lockee1c22882019-06-10 16:02:54 -06004122 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004123 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004124 skip |= LogError(
4125 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4126 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004127 }
4128
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004129 return skip;
4130}
4131
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004132bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4133 VkDeviceSize offset, VkBuffer countBuffer,
4134 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004135 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004136 bool skip = false;
4137
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004138 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004139 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4140 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4141 "), is not a multiple of 4.",
4142 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004143 }
4144
4145 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004146 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4147 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4148 "), is not a multiple of 4.",
4149 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004150 }
4151
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004152 return skip;
4153}
4154
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004155bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004156 const VkAllocationCallbacks *pAllocator,
4157 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004158 bool skip = false;
4159
4160 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4161 if (pCreateInfo != nullptr) {
4162 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4163 // VkQueryPipelineStatisticFlagBits values
4164 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4165 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4167 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4168 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4169 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004170 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004171 if (pCreateInfo->queryCount == 0) {
4172 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4173 "vkCreateQueryPool(): queryCount must be greater than zero.");
4174 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004175 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004176 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004177}
4178
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004179bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4180 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004181 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004182 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4183 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004184}
4185
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004186void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004187 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4188 VkResult result) {
4189 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004190 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004191}
4192
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004193void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004194 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4195 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004196 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004197 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004198 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004199}
4200
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004201void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4202 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004203 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004204 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004205 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004206}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004207
4208bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004209 const VkAllocationCallbacks *pAllocator,
4210 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004211 bool skip = false;
4212
4213 if (pAllocateInfo) {
4214 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4215 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004216 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4217 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004218 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004219
4220 VkMemoryAllocateFlags flags = 0;
4221 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4222 if (flags_info) {
4223 flags = flags_info->flags;
4224 }
4225
4226 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4227 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4228 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004229 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4230 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4231 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004232 }
4233
4234#ifdef VK_USE_PLATFORM_WIN32_KHR
4235 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4236#endif
4237 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4238 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4239#ifdef VK_USE_PLATFORM_ANDROID_KHR
4240 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4241#endif
4242
4243 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004244 skip |= LogError(
4245 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004246 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4247 }
4248 if (
4249#ifdef VK_USE_PLATFORM_WIN32_KHR
4250 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4251#endif
4252 (import_memory_fd && import_memory_fd->handleType) ||
4253#ifdef VK_USE_PLATFORM_ANDROID_KHR
4254 (import_memory_ahb && import_memory_ahb->buffer) ||
4255#endif
4256 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004257 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4258 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004259 }
4260 }
4261
4262 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004263 VkBool32 capture_replay = false;
4264 VkBool32 buffer_device_address = false;
4265 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4266 if (vulkan_12_features) {
4267 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4268 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4269 } else {
4270 const auto *bda_features =
4271 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4272 if (bda_features) {
4273 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4274 buffer_device_address = bda_features->bufferDeviceAddress;
4275 }
4276 }
4277 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004278 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4279 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4280 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004281 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004282 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004283 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4284 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004285 }
4286 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004287 }
4288 return skip;
4289}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004290
Jason Macnak192fa0e2019-07-26 15:07:16 -07004291bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004292 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004293 bool skip = false;
4294
4295 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4296 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4297 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004298 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004299 } else {
4300 uint32_t vertex_component_size = 0;
4301 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4302 vertex_component_size = 4;
4303 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4304 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4305 vertex_component_size = 2;
4306 }
4307 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004308 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004309 }
4310 }
4311
4312 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4313 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004314 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004315 } else {
4316 uint32_t index_element_size = 0;
4317 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4318 index_element_size = 4;
4319 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4320 index_element_size = 2;
4321 }
4322 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004323 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004324 }
4325 }
4326 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4327 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004328 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004329 }
4330 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004331 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004332 }
4333 }
4334
4335 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004336 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004337 }
4338
4339 return skip;
4340}
4341
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004342bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4343 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004344 bool skip = false;
4345
4346 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004347 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004348 }
4349 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004350 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004351 }
4352
4353 return skip;
4354}
4355
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004356bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4357 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004358 bool skip = false;
4359 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004360 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004361 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004362 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004363 }
4364 return skip;
4365}
4366
4367bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004368 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004369 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004370 bool skip = false;
4371 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004372 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4373 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4374 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004375 }
4376 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004377 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4378 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4379 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004380 }
4381 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4382 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004383 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4384 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4385 "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 -07004386 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004387 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004388 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004389 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4390 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004391 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4392 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004393 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004394 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004395 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4396 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4397 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004398 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004399 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004400 uint64_t total_triangle_count = 0;
4401 for (uint32_t i = 0; i < info.geometryCount; i++) {
4402 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004403
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004404 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004405
Jason Macnak5c954952019-07-09 15:46:12 -07004406 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4407 continue;
4408 }
4409 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4410 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004411 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004412 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4413 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4414 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004415 }
4416 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004417 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4418 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4419 for (uint32_t i = 1; i < info.geometryCount; i++) {
4420 const VkGeometryNV &geometry = info.pGeometries[i];
4421 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004422 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004423 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4424 "info.pGeometries[0].geometryType.",
4425 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004426 }
4427 }
4428 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004429 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4430 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4431 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4432 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4433 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4434 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4435 }
4436 }
4437 skip |=
4438 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004439 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004440 return skip;
4441}
4442
Ricardo Garciaa4935972019-02-21 17:43:18 +01004443bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4444 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004445 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004446 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004447 if (pCreateInfo) {
4448 if ((pCreateInfo->compactedSize != 0) &&
4449 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004450 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4451 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4452 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4453 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004454 }
Jason Macnak5c954952019-07-09 15:46:12 -07004455
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004456 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004457 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004458 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004459 return skip;
4460}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004461
Jeff Bolz5c801d12019-10-09 10:38:45 -05004462bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4463 const VkAccelerationStructureInfoNV *pInfo,
4464 VkBuffer instanceData, VkDeviceSize instanceOffset,
4465 VkBool32 update, VkAccelerationStructureNV dst,
4466 VkAccelerationStructureNV src, VkBuffer scratch,
4467 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004468 bool skip = false;
4469
4470 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004471 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004472 }
4473
4474 return skip;
4475}
4476
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004477bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4478 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4479 VkAccelerationStructureKHR *pAccelerationStructure) const {
4480 bool skip = false;
4481
4482 if (pCreateInfo) {
4483 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4484 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4485 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4486 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4487 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4488 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4489 i);
4490 }
4491 }
4492
4493 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4494 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4495 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4496 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4497 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4498 i);
4499 }
4500 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004501 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4502 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4503 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4504 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4505 skip |= LogError(
4506 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4507 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4508 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4509 }
4510 }
4511 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4512 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4513 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4514 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4515 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4516 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4517 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4518 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4519 }
4520 }
4521 }
4522
4523 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4524 pCreateInfo->maxGeometryCount != 1) {
4525 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4526 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4527 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004528 }
sourav parmard1521802020-06-07 21:49:02 -07004529 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4530 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4531 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4532 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4533 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004534
4535 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4536 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4537 skip |= LogError(
4538 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4539 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4540 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4541 }
4542
4543 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4544 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4545 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4546 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4547 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4548 }
4549
4550 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4551 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4552 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4553 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4554 if (geometry_type != first_geometry_type) {
4555 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4556 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4557 "pGeometryInfos[0].geometryType.",
4558 i);
4559 }
4560 }
4561 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004562 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4563 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4564 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4565 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4566 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4567 "maxGeometryCount %d.",
4568 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4569 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004570 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004571 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4572 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4573 if (pCreateInfo->deviceAddress != 0) {
4574 skip |=
4575 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4576 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4577 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4578 }
4579 }
sourav parmar83c31b12020-05-06 12:30:54 -07004580 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4581 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4582 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4583 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004584 return skip;
4585}
4586
Jason Macnak5c954952019-07-09 15:46:12 -07004587bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4588 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004589 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004590 bool skip = false;
4591 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004592 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4593 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004594 }
4595 return skip;
4596}
4597
Peter Chen85366392019-05-14 15:20:11 -04004598bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4599 uint32_t createInfoCount,
4600 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4601 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004602 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004603 bool skip = false;
4604
4605 for (uint32_t i = 0; i < createInfoCount; i++) {
4606 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4607 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004608 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004609 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4610 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4611 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4612 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004613 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004614
4615 const auto *pipeline_cache_contol_features =
4616 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4617 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4618 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4619 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4620 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4621 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4622 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4623 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4624 }
4625 }
4626
sourav parmarf4a78252020-04-10 13:04:21 -07004627 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4628 skip |=
4629 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4630 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4631 }
4632 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4633 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4634 skip |=
4635 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4636 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4637 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4638 }
4639 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4640 if (pCreateInfos[i].basePipelineIndex != -1) {
4641 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4642 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4643 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4644 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4645 "and pCreateInfos->basePipelineIndex is not -1.");
4646 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004647 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4648 skip |=
4649 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4650 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4651 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4652 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4653 "that element.");
4654 }
sourav parmarf4a78252020-04-10 13:04:21 -07004655 }
4656 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4657 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4658 skip |=
4659 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4660 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4661 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4662 "commands pCreateInfos parameter.");
4663 }
4664 } else {
4665 if (pCreateInfos[i].basePipelineIndex != -1) {
4666 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4667 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4668 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4669 }
4670 }
4671 }
4672 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4673 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4674 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4675 }
4676 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4677 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4678 "vkCreateRayTracingPipelinesNV: flags must not include "
4679 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4680 }
4681 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4682 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4683 "vkCreateRayTracingPipelinesNV: flags must not include "
4684 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4685 }
4686 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4687 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4688 "vkCreateRayTracingPipelinesNV: flags must not include "
4689 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4690 }
4691 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4692 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4693 "vkCreateRayTracingPipelinesNV: flags must not include "
4694 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4695 }
4696 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4697 skip |= LogError(
4698 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4699 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4700 }
4701 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4702 skip |= LogError(
4703 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4704 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4705 }
Peter Chen85366392019-05-14 15:20:11 -04004706 }
4707
4708 return skip;
4709}
4710
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004711bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4712 uint32_t createInfoCount,
4713 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4714 const VkAllocationCallbacks *pAllocator,
4715 VkPipeline *pPipelines) const {
4716 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004717 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4718 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4719 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4720 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4721 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004722 for (uint32_t i = 0; i < createInfoCount; i++) {
4723 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4724 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4725 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4726 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4727 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4728 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4729 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4730 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004731 const auto *pipeline_cache_contol_features =
4732 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4733 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4734 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4735 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4736 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4737 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4738 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4739 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4740 }
4741 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004742 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4743 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4744 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4745 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4746 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4747 }
4748 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4749 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4750 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4751 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4752 }
4753 }
4754
sourav parmarf4a78252020-04-10 13:04:21 -07004755 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4756 skip |=
4757 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4758 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4759 }
4760 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4761 if (pCreateInfos[i].pLibraryInterface == NULL)
4762 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4763 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4764 }
4765 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4766 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4767 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4768 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4769 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4770 skip |= LogError(
4771 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4772 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4773 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4774 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4775 "must not be VK_SHADER_UNUSED_KHR");
4776 }
4777 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4778 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4779 skip |= LogError(
4780 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4781 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4782 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4783 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4784 "element must not be VK_SHADER_UNUSED_KHR");
4785 }
4786 }
4787 }
4788 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4789 if (pCreateInfos[i].basePipelineIndex != -1) {
4790 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4791 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4792 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4793 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4794 "and pCreateInfos->basePipelineIndex is not -1.");
4795 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004796 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4797 skip |=
4798 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4799 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4800 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4801 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4802 "element.");
4803 }
sourav parmarf4a78252020-04-10 13:04:21 -07004804 }
4805 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4806 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4807 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4808 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4809 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4810 "commands pCreateInfos parameter %d.",
4811 pCreateInfos[i].basePipelineIndex, createInfoCount);
4812 }
4813 } else {
4814 if (pCreateInfos[i].basePipelineIndex != -1) {
4815 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4816 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4817 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4818 }
4819 }
4820 }
4821 if (pCreateInfos[i].libraries.libraryCount == 0) {
4822 if (pCreateInfos[i].stageCount == 0) {
4823 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4824 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4825 }
4826 if (pCreateInfos[i].groupCount == 0) {
4827 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4828 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4829 }
4830 } else {
4831 if (pCreateInfos[i].pLibraryInterface == NULL) {
4832 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4833 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4834 }
4835 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004836 }
4837
4838 return skip;
4839}
4840
Mike Schuchardt21638df2019-03-16 10:52:02 -07004841#ifdef VK_USE_PLATFORM_WIN32_KHR
4842bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4843 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004844 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004845 bool skip = false;
4846 if (!device_extensions.vk_khr_swapchain)
4847 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4848 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4849 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4850 if (!device_extensions.vk_khr_surface)
4851 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4852 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4853 skip |=
4854 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4855 if (!device_extensions.vk_ext_full_screen_exclusive)
4856 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4857 skip |= validate_struct_type(
4858 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4859 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4860 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4861 if (pSurfaceInfo != NULL) {
4862 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4863 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4864 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4865
4866 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4867 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4868 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4869 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004870 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4871 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004872
4873 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4874 }
4875 return skip;
4876}
4877#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004878
4879bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4880 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004881 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004882 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4883 bool skip = false;
4884 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4885 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4886 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4887 }
4888 return skip;
4889}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004890
4891bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004892 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004893 bool skip = false;
4894
4895 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004896 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4897 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004898 }
4899
4900 return skip;
4901}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004902
4903bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004904 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004905 bool skip = false;
4906
4907 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004908 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4909 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004910 }
4911
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004912 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004913 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004914 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4915 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004916 }
4917
4918 return skip;
4919}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004920
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004921bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4922 uint32_t bindingCount, const VkBuffer *pBuffers,
4923 const VkDeviceSize *pOffsets) const {
4924 bool skip = false;
4925 if (firstBinding > device_limits.maxVertexInputBindings) {
4926 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4927 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4928 device_limits.maxVertexInputBindings);
4929 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4930 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4931 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4932 "maxVertexInputBindings (%u)",
4933 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4934 }
4935
Jeff Bolz165818a2020-05-08 11:19:03 -05004936 for (uint32_t i = 0; i < bindingCount; ++i) {
4937 if (pBuffers[i] == VK_NULL_HANDLE) {
4938 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4939 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4940 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4941 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4942 } else {
4943 if (pOffsets[i] != 0) {
4944 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4945 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4946 }
4947 }
4948 }
4949 }
4950
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004951 return skip;
4952}
4953
Mark Lobodzinski84988402019-09-11 15:27:30 -06004954bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004955 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004956 bool skip = false;
4957 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004958 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4959 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004960 }
4961 return skip;
4962}
4963
4964bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004965 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004966 bool skip = false;
4967 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004968 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4969 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004970 }
4971 return skip;
4972}
Petr Kraus3d720392019-11-13 02:52:39 +01004973
4974bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4975 VkSemaphore semaphore, VkFence fence,
4976 uint32_t *pImageIndex) const {
4977 bool skip = false;
4978
4979 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004980 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4981 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004982 }
4983
4984 return skip;
4985}
4986
4987bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4988 uint32_t *pImageIndex) const {
4989 bool skip = false;
4990
4991 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004992 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4993 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004994 }
4995
4996 return skip;
4997}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004998
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004999bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5000 uint32_t firstBinding, uint32_t bindingCount,
5001 const VkBuffer *pBuffers,
5002 const VkDeviceSize *pOffsets,
5003 const VkDeviceSize *pSizes) const {
5004 bool skip = false;
5005
5006 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5007 for (uint32_t i = 0; i < bindingCount; ++i) {
5008 if (pOffsets[i] & 3) {
5009 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5010 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5011 }
5012 }
5013
5014 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5015 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5016 "%s: The firstBinding(%" PRIu32
5017 ") index is greater than or equal to "
5018 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5019 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5020 }
5021
5022 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5023 skip |=
5024 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5025 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5026 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5027 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5028 }
5029
5030 for (uint32_t i = 0; i < bindingCount; ++i) {
5031 // pSizes is optional and may be nullptr.
5032 if (pSizes != nullptr) {
5033 if (pSizes[i] != VK_WHOLE_SIZE &&
5034 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5035 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5036 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5037 ") is not VK_WHOLE_SIZE and is greater than "
5038 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5039 cmd_name, i, pSizes[i]);
5040 }
5041 }
5042 }
5043
5044 return skip;
5045}
5046
5047bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5048 uint32_t firstCounterBuffer,
5049 uint32_t counterBufferCount,
5050 const VkBuffer *pCounterBuffers,
5051 const VkDeviceSize *pCounterBufferOffsets) const {
5052 bool skip = false;
5053
5054 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5055 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5056 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5057 "%s: The firstCounterBuffer(%" PRIu32
5058 ") index is greater than or equal to "
5059 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5060 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5061 }
5062
5063 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5064 skip |=
5065 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5066 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5067 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5068 cmd_name, firstCounterBuffer, counterBufferCount,
5069 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5070 }
5071
5072 return skip;
5073}
5074
5075bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5076 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5077 const VkBuffer *pCounterBuffers,
5078 const VkDeviceSize *pCounterBufferOffsets) const {
5079 bool skip = false;
5080
5081 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5082 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5083 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5084 "%s: The firstCounterBuffer(%" PRIu32
5085 ") index is greater than or equal to "
5086 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5087 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5088 }
5089
5090 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5091 skip |=
5092 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5093 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5094 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5095 cmd_name, firstCounterBuffer, counterBufferCount,
5096 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5097 }
5098
5099 return skip;
5100}
5101
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005102bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5103 uint32_t firstInstance, VkBuffer counterBuffer,
5104 VkDeviceSize counterBufferOffset,
5105 uint32_t counterOffset, uint32_t vertexStride) const {
5106 bool skip = false;
5107
5108 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005109 skip |= LogError(
5110 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005111 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5112 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5113 }
5114
5115 return skip;
5116}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005117
5118bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5119 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5120 const VkAllocationCallbacks *pAllocator,
5121 VkSamplerYcbcrConversion *pYcbcrConversion,
5122 const char *apiName) const {
5123 bool skip = false;
5124
5125 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005126 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005127 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005128 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5129 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5130 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005131 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005132 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005133 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005134
5135 const VkComponentMapping components = pCreateInfo->components;
5136 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5137 if (FormatIsXChromaSubsampled(pCreateInfo->format) == true) {
5138 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5139 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
5140 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5141 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
5142 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.g));
5143 }
5144
5145 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5146 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5147 skip |=
5148 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5149 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5150 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5151 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.a));
5152 }
5153
5154 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5155 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5156 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
5157 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5158 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
5159 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.r));
5160 }
5161
5162 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5163 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5164 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
5165 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5166 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
5167 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.b));
5168 }
5169
5170 // If one is identity, both need to be
5171 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5172 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5173 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5174 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
5175 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5176 "are an identity swizzle, then both need to be an identity swizzle.",
5177 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.r),
5178 string_VkComponentSwizzle(components.b));
5179 }
5180 }
5181
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005182 return skip;
5183}
5184
5185bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5186 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5187 const VkAllocationCallbacks *pAllocator,
5188 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5189 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5190 "vkCreateSamplerYcbcrConversion");
5191}
5192
5193bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5194 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5195 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5196 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5197 "vkCreateSamplerYcbcrConversionKHR");
5198}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005199
5200bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5201 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5202 bool skip = false;
5203 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5204 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5205
5206 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005207 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5208 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5209 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5210 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5211 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005212 }
5213 return skip;
5214}
sourav parmara96ab1a2020-04-25 16:28:23 -07005215
5216bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5217 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5218 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005219 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5220 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5221 skip |=
5222 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5223 "vkCopyAccelerationStructureToMemoryKHR: the "
5224 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5225 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005226 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5227 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5228 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5229 }
5230 return skip;
5231}
5232
5233bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5234 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5235 bool skip = false;
5236 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5237 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5238 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5239 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5240 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005241 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5242 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005243 skip |= LogError(
5244 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5245 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5246 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5247 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005248 return skip;
5249}
5250
5251bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5252 const char *api_name) const {
5253 bool skip = false;
5254 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5255 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5256 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5257 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5258 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5259 api_name);
5260 }
5261 return skip;
5262}
5263
5264bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5265 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5266 bool skip = false;
5267 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005268 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5269 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5270 skip |= LogError(
5271 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5272 "vkCopyAccelerationStructureKHR(): the "
5273 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5274 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005275 return skip;
5276}
5277
5278bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5279 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5280 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005281 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5282 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005283 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5284 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5285 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5286 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005287 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5288 return skip;
5289}
5290
5291bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005292 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005293 bool skip = false;
5294 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005295 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005296 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005297 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005298 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5299 }
5300 return skip;
5301}
5302
5303bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5304 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5305 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005306 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5307 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5308 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5309 skip |=
5310 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5311 "vkCopyMemoryToAccelerationStructureKHR() :the "
5312 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5313 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005314 return skip;
5315}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005316
sourav parmara96ab1a2020-04-25 16:28:23 -07005317bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5318 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5319 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005320 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5321 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005322 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5323 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5324 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5325 }
sourav parmar83c31b12020-05-06 12:30:54 -07005326 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5327 return skip;
5328}
5329bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5330 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5331 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5332 bool skip = false;
5333 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5334 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5335 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5336 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5337 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5338 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5339 }
5340 return skip;
5341}
5342bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5343 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5344 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5345 bool skip = false;
5346 if (dataSize < accelerationStructureCount * stride) {
5347 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5348 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5349 "accelerationStructureCount (%d) *stride(%zu).",
5350 dataSize, accelerationStructureCount, stride);
5351 }
5352 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5353 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5354 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5355 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5356 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5357 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5358 }
5359 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5360 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5361 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5362 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5363 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5364 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5365 stride);
5366 }
5367 }
5368 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5369 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5370 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5371 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5372 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5373 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5374 stride);
5375 }
5376 }
5377 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5378 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5379 skip |=
5380 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5381 "vkWriteAccelerationStructuresPropertiesKHR: the "
5382 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5383 "feature must be enabled ");
5384 }
5385 return skip;
5386}
5387bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5388 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5389 bool skip = false;
5390 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5391 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5392 skip |= LogError(device,
5393 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5394 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5395 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5396 "must be enabled to call this function.");
5397 }
5398 return skip;
5399}
5400
5401bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5402 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5403 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5404 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5405 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5406 uint32_t width, uint32_t height, uint32_t depth) const {
5407 bool skip = false;
5408 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5409 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5410 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5411 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5412 }
5413 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5414 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5415 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5416 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5417 }
5418 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5419 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5420 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5421 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5422 }
5423 // hitShader
5424 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5425 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5426 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5427 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5428 }
5429 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5430 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5431 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5432 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5433 }
5434 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5435 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5436 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5437 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5438 }
5439
5440 // missShader
5441 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5442 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5443 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5444 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5445 }
5446 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5447 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5448 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5449 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5450 }
5451 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5452 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5453 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5454 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5455 }
5456
5457 // raygenShader
5458 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5459 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5460 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5461 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5462 }
5463 return skip;
5464}
5465
5466bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5467 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5468 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5469 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5470 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5471 VkBuffer buffer, VkDeviceSize offset) const {
5472 bool skip = false;
5473 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5474 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5475 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5476 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5477 "feature must be enabled.");
5478 }
5479 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5480 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5481 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5482 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5483 }
5484 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5485 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5486 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5487 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5488 }
5489 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5490 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5491 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5492 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5493 }
5494 // hitShader
5495 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5496 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5497 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5498 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5499 }
5500 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5501 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5502 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5503 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5504 }
5505 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5506 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5507 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5508 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5509 }
5510
5511 // missShader
5512 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5513 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5514 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5515 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5516 }
5517 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5518 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5519 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5520 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5521 }
5522 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5523 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5524 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5525 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5526 }
5527
5528 // raygenShader
5529 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5530 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5531 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5532 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5533 }
5534 return skip;
5535}
5536bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5537 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5538 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5539 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5540 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5541 uint32_t width, uint32_t height, uint32_t depth) const {
5542 bool skip = false;
5543 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5544 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5545 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5546 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5547 }
5548 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5549 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5550 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5551 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5552 }
5553 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5554 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5555 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5556 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5557 }
5558
5559 // hitShader
5560 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5561 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5562 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5563 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5564 }
5565 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5566 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5567 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5568 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5569 }
5570 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5571 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5572 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5573 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5574 }
5575
5576 // missShader
5577 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5578 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5579 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5580 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5581 }
5582 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5583 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5584 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5585 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5586 }
5587 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5588 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5589 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5590 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5591 }
5592
5593 // raygenShader
5594 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5595 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5596 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005597 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5598 }
5599 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5600 skip |=
5601 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5602 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5603 }
5604 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5605 skip |=
5606 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5607 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5608 }
5609 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5610 skip |=
5611 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5612 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005613 }
5614 return skip;
5615}
5616
5617bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5618 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5619 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5620 bool skip = false;
5621 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5622 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5623 skip |= LogError(
5624 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5625 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5626 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5627 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005628 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5629 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005630 skip |=
5631 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5632 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5633 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5634 }
5635 return false;
5636}
5637
5638bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5639 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5640 bool skip = false;
5641 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5642 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5643 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5644 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5645 }
5646 return skip;
5647}
5648
5649bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5650 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5651 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5652 bool skip = false;
5653 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5654 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005655 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5656 "vkBuildAccelerationStructureKHR: The "
5657 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5658 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005659 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005660 return skip;
5661}
sourav parmara24fb7b2020-05-26 10:50:04 -07005662bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5663 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5664 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5665 bool skip = false;
5666 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005667 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5668 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005669 skip |=
5670 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5671 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5672 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5673 }
5674 }
5675 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005676}
Piers Daniell39842ee2020-07-10 16:42:33 -06005677
5678bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5679 const VkViewport *pViewports) const {
5680 bool skip = false;
5681
5682 if (!physical_device_features.multiViewport) {
5683 if (viewportCount != 1) {
5684 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5685 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5686 ") is not 1.",
5687 viewportCount);
5688 }
5689 } else { // multiViewport enabled
5690 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5691 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5692 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5693 ") must "
5694 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5695 viewportCount, device_limits.maxViewports);
5696 }
5697 }
5698
5699 if (pViewports) {
5700 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5701 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5702 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5703 skip |= manual_PreCallValidateViewport(
5704 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5705 }
5706 }
5707
5708 return skip;
5709}
5710
5711bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5712 const VkRect2D *pScissors) const {
5713 bool skip = false;
5714
5715 if (!physical_device_features.multiViewport) {
5716 if (scissorCount != 1) {
5717 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5718 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5719 ") must "
5720 "be 1 when the multiViewport feature is disabled.",
5721 scissorCount);
5722 }
5723 } else { // multiViewport enabled
5724 if (scissorCount == 0) {
5725 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5726 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5727 ") must "
5728 "be great than zero.",
5729 scissorCount);
5730 } else if (scissorCount > device_limits.maxViewports) {
5731 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5732 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5733 ") must "
5734 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5735 scissorCount, device_limits.maxViewports);
5736 }
5737 }
5738
5739 if (pScissors) {
5740 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5741 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5742
5743 if (scissor.offset.x < 0) {
5744 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5745 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5746 scissor.offset.x);
5747 }
5748
5749 if (scissor.offset.y < 0) {
5750 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5751 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5752 scissor.offset.y);
5753 }
5754
5755 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5756 if (x_sum > INT32_MAX) {
5757 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5758 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5759 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5760 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5761 }
5762
5763 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5764 if (y_sum > INT32_MAX) {
5765 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5766 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5767 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5768 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5769 }
5770 }
5771 }
5772
5773 return skip;
5774}
5775
5776bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5777 uint32_t bindingCount, const VkBuffer *pBuffers,
5778 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5779 const VkDeviceSize *pStrides) const {
5780 bool skip = false;
5781 if (firstBinding >= device_limits.maxVertexInputBindings) {
5782 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5783 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5784 firstBinding, device_limits.maxVertexInputBindings);
5785 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5786 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5787 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5788 "maxVertexInputBindings (%u)",
5789 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5790 }
5791
5792 for (uint32_t i = 0; i < bindingCount; ++i) {
5793 if (pBuffers[i] == VK_NULL_HANDLE) {
5794 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5795 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5796 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5797 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5798 } else {
5799 if (pOffsets[i] != 0) {
5800 skip |=
5801 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5802 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5803 }
5804 }
5805 }
5806 if (pStrides) {
5807 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5808 skip |=
5809 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5810 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5811 pStrides[i], device_limits.maxVertexInputBindingStride);
5812 }
5813 }
5814 }
5815
5816 return skip;
5817}