blob: ebee5c8932d1b1fd20f2e38c7f91f3c532a5550f [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
300
Locke77fad1c2019-04-16 13:09:03 -0600301 auto vertex_attribute_divisor_features =
302 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
303 if (vertex_attribute_divisor_features) {
304 bool extension_found = false;
305 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
306 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
307 VK_MAX_EXTENSION_NAME_SIZE)) {
308 extension_found = true;
309 break;
310 }
311 }
312 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700313 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
314 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
315 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600316 }
317 }
318
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
320 if (vulkan_11_features) {
321 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
322 while (current) {
323 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
324 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
325 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
326 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
327 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
328 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700329 skip |= LogError(
330 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700331 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
332 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
333 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
334 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
335 break;
336 }
337 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
338 }
339 }
340
341 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
342 if (vulkan_12_features) {
343 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
344 while (current) {
345 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
346 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
347 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
348 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
349 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
350 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
351 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700358 skip |= LogError(
359 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700360 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
361 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
362 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
363 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
364 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
365 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
366 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
367 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
368 break;
369 }
370 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
371 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700372 // Check features are enabled if matching extension is passed in as well
373 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
374 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
375 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
376 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
377 skip |= LogError(
378 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
379 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
380 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
381 }
382 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
383 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
384 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
386 "is not VK_TRUE.",
387 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
388 }
389 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
390 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
391 skip |= LogError(
392 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
393 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
394 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
395 }
396 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
397 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
398 skip |= LogError(
399 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
400 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
401 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
402 }
403 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
404 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
405 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
406 skip |=
407 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
408 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
409 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
410 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
411 }
412 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700413 }
414
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600415 // Validate pCreateInfo->pQueueCreateInfos
416 if (pCreateInfo->pQueueCreateInfos) {
417 std::unordered_set<uint32_t> set;
418
419 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700420 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
421 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600422 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700423 skip |=
424 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
425 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
426 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
427 "index value.",
428 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600429 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
432 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
433 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 } else {
435 set.insert(requested_queue_family);
436 }
437
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700438 if (queue_create_info.pQueuePriorities != nullptr) {
439 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
440 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600441 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700442 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
443 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
444 "] (=%f) is not between 0 and 1 (inclusive).",
445 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600446 }
447 }
448 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700449
450 // Need to know if protectedMemory feature is passed in preCall to creating the device
451 VkBool32 protectedMemory = VK_FALSE;
452 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
453 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
454 if (protected_features) {
455 protectedMemory = protected_features->protectedMemory;
456 } else if (vulkan_11_features) {
457 protectedMemory = vulkan_11_features->protectedMemory;
458 }
459 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
460 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
461 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
462 "protectedMemory feature being set as well.");
463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600464 }
465 }
466
467 return skip;
468}
469
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500470bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700471 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700472 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
473 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
474 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600475 }
476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700477 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600478}
479
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700480bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500481 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100482 bool skip = false;
483
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700485 skip |=
486 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600487
488 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
489 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
490 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
491 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700492 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
493 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
494 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600495 }
496
497 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
498 // queueFamilyIndexCount uint32_t values
499 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700500 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
501 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
502 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
503 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600504 }
505 }
506
507 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
508 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
509 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
510 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
512 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
513 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600514 }
515 }
516
517 return skip;
518}
519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700520bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500521 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600522 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523
524 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
526 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
527 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
528 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700529 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
530 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
531 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 }
533
534 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
535 // queueFamilyIndexCount uint32_t values
536 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
538 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
540 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542 }
543
Dave Houlton413a6782018-05-22 13:01:54 -0600544 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600546 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600548 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700549 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600550
Dave Houlton413a6782018-05-22 13:01:54 -0600551 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600553 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700554 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555
Dave Houlton130c0212018-01-29 13:39:56 -0700556 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700557 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
558 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(
560 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600561 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
562 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700563 }
564
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600565 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100566 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
567 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700568 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
569 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
570 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600571 }
572
573 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100574 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
575 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
577 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
578 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
579 ") are not equal.",
580 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100581 }
582
583 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700584 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
585 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
586 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
587 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100588 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600589 }
590
591 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 skip |= LogError(
593 device, "VUID-VkImageCreateInfo-imageType-00957",
594 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595 }
596 }
597
Dave Houlton130c0212018-01-29 13:39:56 -0700598 // 3D image may have only 1 layer
599 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
601 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700602 }
603
604 // If multi-sample, validate type, usage, tiling and mip levels.
605 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
606 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600607 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700608 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
609 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700610 }
611
612 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
613 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
614 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
615 // At least one of the legal attachment bits must be set
616 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700617 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
618 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700619 }
620 // No flags other than the legal attachment bits may be set
621 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
622 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
624 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700625 }
626 }
627
Jeff Bolzef40fec2018-09-01 22:04:34 -0500628 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500630 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600631 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
632 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500633 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600634 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700635 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
636 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
637 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638 }
639
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600640 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700641 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
642 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
643 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600644 }
645
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700646 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700647 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
648 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
649 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100650 }
651
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600652 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
653 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
654 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
655 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700656 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
657 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
658 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600659 }
660
661 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
662 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
663 // Linear tiling is unsupported
664 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700665 skip |= LogError(device, kVUID_PVError_InvalidUsage,
666 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
667 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600668 }
669
670 // Sparse 1D image isn't valid
671 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700672 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
673 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 }
675
676 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700677 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700678 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
679 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
680 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600681 }
682
683 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700684 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700685 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
686 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
687 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600688 }
689
690 // Multi-sample 2D image when device doesn't support it
691 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700692 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
695 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
696 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700697 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
700 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
701 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700702 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700704 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
705 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
706 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700707 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600708 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
710 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
711 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712 }
713 }
714 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500715
Jeff Bolz9af91c52018-09-01 21:53:57 -0500716 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
717 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
719 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
720 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500721 }
722 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
724 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
725 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500726 }
727 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
729 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
730 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500731 }
732 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500733
734 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600735 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
737 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
738 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500739 }
740
Dave Houlton142c4cb2018-10-17 15:04:41 -0600741 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
743 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
744 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
745 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500746 }
747
Dave Houlton142c4cb2018-10-17 15:04:41 -0600748 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
750 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
751 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
752 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500753 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600754 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700755 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
756 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
757 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
758 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500759 }
760 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500761
sfricke-samsung8f658d42020-05-03 20:12:24 -0700762 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
763 (FormatHasDepth(pCreateInfo->format) == false)) {
764 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
765 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
766 "format must be a depth or depth/stencil format.");
767 }
768
Andrew Fobel3abeb992020-01-20 16:33:22 -0500769 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
770 if (image_stencil_struct != nullptr) {
771 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
772 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
773 // No flags other than the legal attachment bits may be set
774 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
775 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700776 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
777 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
778 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
779 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500780 }
781 }
782
783 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
784 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
785 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
786 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
788 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
789 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
790 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500791 }
792
793 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
794 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 LogError(device, "VUID-VkImageCreateInfo-format-02537",
796 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
797 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
798 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500799 }
800 }
801
802 if (!physical_device_features.shaderStorageImageMultisample &&
803 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
804 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
805 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 LogError(device, "VUID-VkImageCreateInfo-format-02538",
807 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
808 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
809 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500810 }
811
812 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
813 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 skip |= LogError(
815 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500816 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
817 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
818 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
819 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
820 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(
822 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500823 "vkCreateImage(): Depth-stencil image in which usage does not include "
824 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
825 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
826 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
827 }
828
829 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
830 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700831 skip |= LogError(
832 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500833 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
834 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
835 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
836 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
837 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(
839 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500840 "vkCreateImage(): Depth-stencil image in which usage does not include "
841 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
842 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
843 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
844 }
845 }
846 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700847
848 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
849 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
850 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
851 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
852 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
853 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700854
855 if (device_extensions.vk_ext_image_drm_format_modifier) {
856 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
857 const auto drm_format_mod_explict =
858 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
859 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
860 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
861 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
862 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
863 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
864 "either VkImageDrmFormatModifierListCreateInfoEXT or "
865 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
866 }
867 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
868 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
869 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
870 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
871 "in the pNext chain");
872 }
873 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200874
875 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
876 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
877 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
878 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
879 "imageType must be VK_IMAGE_TYPE_2D.");
880 }
881 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
882 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
883 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
884 "samples must be VK_SAMPLE_COUNT_1_BIT.");
885 }
886 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
887 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
888 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
889 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
890 }
891 }
892 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
893 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
894 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
895 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
896 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
897 }
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
900 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
902 }
903 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
904 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
905 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
906 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
907 }
908 if (pCreateInfo->mipLevels != 1) {
909 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
910 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
911 pCreateInfo->mipLevels);
912 }
913 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600914 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500915
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600916 return skip;
917}
918
Jeff Bolz99e3f632020-03-24 22:59:22 -0500919bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
920 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
921 bool skip = false;
922
923 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700924 // Validate feature set if using CUBE_ARRAY
925 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
926 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
927 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
928 "enabling the imageCubeArray feature.");
929 }
930
Jeff Bolz99e3f632020-03-24 22:59:22 -0500931 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
932 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
933 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700934 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500935 pCreateInfo->subresourceRange.layerCount);
936 }
937 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700938 skip |= LogError(
939 device, "VUID-VkImageViewCreateInfo-viewType-02961",
940 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
941 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500942 }
943 }
944 }
945 return skip;
946}
947
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600948bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100950 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100951
952 // Note: for numerical correctness
953 // - float comparisons should expect NaN (comparison always false).
954 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
955
956 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700957 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100958 if (v1_f <= 0.0f) return true;
959
960 float intpart;
961 const float fract = modff(v1_f, &intpart);
962
963 assert(std::numeric_limits<float>::radix == 2);
964 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
965 if (intpart >= u32_max_plus1) return false;
966
967 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
968 if (v1_u32 < v2_u32)
969 return true;
970 else if (v1_u32 == v2_u32 && fract == 0.0f)
971 return true;
972 else
973 return false;
974 };
975
976 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
977 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
978 return (v1_f <= v2_f);
979 };
980
981 // width
982 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700983 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100984
985 if (!(viewport.width > 0.0f)) {
986 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700987 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
988 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100989 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
990 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(object, "VUID-VkViewport-width-01771",
992 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
993 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100994 } 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 -0700995 skip |= LogWarning(object, kVUID_PVError_NONE,
996 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
997 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
998 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100999 }
1000
1001 // height
1002 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001003 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001004 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001005
1006 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1007 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1009 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001010 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1011 height_healthy = false;
1012
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 skip |= LogError(object, "VUID-VkViewport-height-01773",
1014 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1015 ").",
1016 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001017 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1018 height_healthy = false;
1019
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001020 skip |= LogWarning(
1021 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001022 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001023 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001024 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001025 }
1026
1027 // x
1028 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001029 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001030 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001031 skip |= LogError(object, "VUID-VkViewport-x-01774",
1032 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1033 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001034 }
1035
1036 // x + width
1037 if (x_healthy && width_healthy) {
1038 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001039 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001040 skip |= LogError(
1041 object, "VUID-VkViewport-x-01232",
1042 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1043 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1044 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001045 }
1046 }
1047
1048 // y
1049 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001050 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001051 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001052 skip |= LogError(object, "VUID-VkViewport-y-01775",
1053 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1054 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001055 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001056 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001057 skip |= LogError(object, "VUID-VkViewport-y-01776",
1058 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1059 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001060 }
1061
1062 // y + height
1063 if (y_healthy && height_healthy) {
1064 const float boundary = viewport.y + viewport.height;
1065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001066 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001067 skip |= LogError(object, "VUID-VkViewport-y-01233",
1068 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1069 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1070 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001071 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001072 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001073 LogError(object, "VUID-VkViewport-y-01777",
1074 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1075 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1076 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001077 }
1078 }
1079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001080 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001081 // minDepth
1082 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001083 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001084
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001085 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1086 "[0.0, 1.0] range.",
1087 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001088 }
1089
1090 // maxDepth
1091 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001092 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001093
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001094 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1095 "[0.0, 1.0] range.",
1096 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001097 }
1098 }
1099
1100 return skip;
1101}
1102
Dave Houlton142c4cb2018-10-17 15:04:41 -06001103struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001104 VkShadingRatePaletteEntryNV shadingRate;
1105 uint32_t width;
1106 uint32_t height;
1107};
1108
1109// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001110static SampleOrderInfo sampleOrderInfos[] = {
1111 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1112 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1113 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1114 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1115 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1116 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001117};
1118
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001119bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001120 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001121
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001122 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001123 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001124 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001125 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001126 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001127 break;
1128 }
1129 }
1130
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001131 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001132 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1133 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1134 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001135 return skip;
1136 }
1137
Dave Houlton142c4cb2018-10-17 15:04:41 -06001138 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001139 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001140 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1141 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1142 ") must "
1143 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1144 "is set in framebufferNoAttachmentsSampleCounts.",
1145 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001146 }
1147
Jeff Bolz9af91c52018-09-01 21:53:57 -05001148 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001149 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1150 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1151 ") must "
1152 "be equal to the product of sampleCount (=%" PRIu32
1153 "), the fragment width for shadingRate "
1154 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1155 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001156 }
1157
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001158 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001159 skip |= LogError(
1160 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001161 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1162 ") must "
1163 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001164 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001165 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001166
1167 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001168 // the first width*height*sampleCount bits to all be set. Note: There is no
1169 // guarantee that 64 bits is enough, but practically it's unlikely for an
1170 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001171 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001172 uint64_t sampleLocationsMask = 0;
1173 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1174 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1175 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001176 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1177 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001178 }
1179 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001180 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1181 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001182 }
1183 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001184 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1185 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001186 }
1187 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1188 sampleLocationsMask |= 1ULL << idx;
1189 }
1190
1191 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1192 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001193 skip |= LogError(
1194 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001195 "The array pSampleLocations must contain exactly one entry for "
1196 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001197 }
1198
1199 return skip;
1200}
1201
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001202bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1203 uint32_t createInfoCount,
1204 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1205 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001206 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001208
1209 if (pCreateInfos != nullptr) {
1210 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001211 bool has_dynamic_viewport = false;
1212 bool has_dynamic_scissor = false;
1213 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001214 bool has_dynamic_depth_bias = false;
1215 bool has_dynamic_blend_constant = false;
1216 bool has_dynamic_depth_bounds = false;
1217 bool has_dynamic_stencil_compare = false;
1218 bool has_dynamic_stencil_write = false;
1219 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001220 bool has_dynamic_viewport_w_scaling_nv = false;
1221 bool has_dynamic_discard_rectangle_ext = false;
1222 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001223 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001224 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001225 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001226 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001227 if (pCreateInfos[i].pDynamicState != nullptr) {
1228 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1229 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1230 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001231 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1232 if (has_dynamic_viewport == true) {
1233 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1234 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1235 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1236 i);
1237 }
1238 has_dynamic_viewport = true;
1239 }
1240 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1241 if (has_dynamic_scissor == true) {
1242 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1243 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1244 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1245 i);
1246 }
1247 has_dynamic_scissor = true;
1248 }
1249 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1250 if (has_dynamic_line_width == true) {
1251 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1252 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1253 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1254 i);
1255 }
1256 has_dynamic_line_width = true;
1257 }
1258 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1259 if (has_dynamic_depth_bias == true) {
1260 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1261 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1262 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1263 i);
1264 }
1265 has_dynamic_depth_bias = true;
1266 }
1267 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1268 if (has_dynamic_blend_constant == true) {
1269 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1270 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1271 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1272 i);
1273 }
1274 has_dynamic_blend_constant = true;
1275 }
1276 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1277 if (has_dynamic_depth_bounds == true) {
1278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1280 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1281 i);
1282 }
1283 has_dynamic_depth_bounds = true;
1284 }
1285 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1286 if (has_dynamic_stencil_compare == true) {
1287 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1288 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1289 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1290 i);
1291 }
1292 has_dynamic_stencil_compare = true;
1293 }
1294 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1295 if (has_dynamic_stencil_write == true) {
1296 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1297 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1298 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1299 i);
1300 }
1301 has_dynamic_stencil_write = true;
1302 }
1303 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1304 if (has_dynamic_stencil_reference == true) {
1305 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1306 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1307 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1308 i);
1309 }
1310 has_dynamic_stencil_reference = true;
1311 }
1312 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1313 if (has_dynamic_viewport_w_scaling_nv == true) {
1314 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1315 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1316 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1317 i);
1318 }
1319 has_dynamic_viewport_w_scaling_nv = true;
1320 }
1321 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1322 if (has_dynamic_discard_rectangle_ext == true) {
1323 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1324 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1325 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1326 i);
1327 }
1328 has_dynamic_discard_rectangle_ext = true;
1329 }
1330 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1331 if (has_dynamic_sample_locations_ext == true) {
1332 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1333 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1334 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1335 i);
1336 }
1337 has_dynamic_sample_locations_ext = true;
1338 }
1339 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1340 if (has_dynamic_exclusive_scissor_nv == true) {
1341 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1342 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1343 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1344 i);
1345 }
1346 has_dynamic_exclusive_scissor_nv = true;
1347 }
1348 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1349 if (has_dynamic_shading_rate_palette_nv == true) {
1350 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1351 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1352 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1353 i);
1354 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001355 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001356 }
1357 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1358 if (has_dynamic_viewport_course_sample_order_nv == true) {
1359 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1360 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1361 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1362 i);
1363 }
1364 has_dynamic_viewport_course_sample_order_nv = true;
1365 }
1366 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1367 if (has_dynamic_line_stipple == true) {
1368 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1369 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1370 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1371 i);
1372 }
1373 has_dynamic_line_stipple = true;
1374 }
Petr Kraus299ba622017-11-24 03:09:03 +01001375 }
1376 }
1377
Peter Chen85366392019-05-14 15:20:11 -04001378 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1379 if ((feedback_struct != nullptr) &&
1380 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1382 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1383 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1384 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1385 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001386 }
1387
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001388 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001389
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001390 // Collect active stages and other information
1391 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001392 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001393 bool has_eval = false;
1394 bool has_control = false;
1395 if (pCreateInfos[i].pStages != nullptr) {
1396 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1397 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1398
1399 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1400 has_control = true;
1401 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1402 has_eval = true;
1403 }
1404
1405 skip |= validate_string(
1406 "vkCreateGraphicsPipelines",
1407 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1408 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1409 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001410 }
1411
1412 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1413 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1414 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1415 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1416 pCreateInfos[i].pTessellationState,
1417 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1418 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1419
1420 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1421 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1422
1423 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1424 "VkPipelineTessellationDomainOriginStateCreateInfo",
1425 pCreateInfos[i].pTessellationState->pNext,
1426 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1427 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001428 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1429 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001430
1431 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1432 pCreateInfos[i].pTessellationState->flags,
1433 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1434 }
1435
1436 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1437 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1438 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1439 pCreateInfos[i].pInputAssemblyState,
1440 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1441 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1442
1443 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1444 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001445 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001446
1447 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1448 pCreateInfos[i].pInputAssemblyState->flags,
1449 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1450
1451 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1452 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1453 pCreateInfos[i].pInputAssemblyState->topology,
1454 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1455
1456 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1457 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1458 }
1459
1460 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001461 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001462
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001463 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1465 "vkCreateGraphicsPipelines: pararameter "
1466 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1467 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001468 }
1469
1470 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1471 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1472 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1473 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1474 pCreateInfos[i].pVertexInputState->pNext, 1,
1475 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001476 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1477 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001478 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1479 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001480 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001481 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1482 skip |=
1483 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1484 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1485 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1486 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1487 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1488
1489 skip |= validate_array(
1490 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1491 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1492 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1493 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1494
1495 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1496 for (uint32_t vertexBindingDescriptionIndex = 0;
1497 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1498 ++vertexBindingDescriptionIndex) {
1499 skip |= validate_ranged_enum(
1500 "vkCreateGraphicsPipelines",
1501 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1502 AllVkVertexInputRateEnums,
1503 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1504 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1505 }
1506 }
1507
1508 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1509 for (uint32_t vertexAttributeDescriptionIndex = 0;
1510 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1511 ++vertexAttributeDescriptionIndex) {
1512 skip |= validate_ranged_enum(
1513 "vkCreateGraphicsPipelines",
1514 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1515 AllVkFormatEnums,
1516 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1517 "VUID-VkVertexInputAttributeDescription-format-parameter");
1518 }
1519 }
1520
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001521 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001522 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1523 "vkCreateGraphicsPipelines: pararameter "
1524 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1525 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1526 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001527 }
1528
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001529 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001530 skip |=
1531 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1532 "vkCreateGraphicsPipelines: pararameter "
1533 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1534 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1535 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001536 }
1537
1538 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001539 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1540 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001541 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1542 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001543 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1544 "vkCreateGraphicsPipelines: parameter "
1545 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1546 "(%" PRIu32 ") is not distinct.",
1547 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001548 }
1549 vertex_bindings.insert(vertex_bind_desc.binding);
1550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001551 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001552 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1553 "vkCreateGraphicsPipelines: parameter "
1554 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1555 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1556 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001557 }
1558
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001559 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001560 skip |=
1561 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1562 "vkCreateGraphicsPipelines: parameter "
1563 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1564 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1565 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001566 }
1567 }
1568
Peter Kohautc7d9d392018-07-15 00:34:07 +02001569 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001570 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1571 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001572 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1573 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001574 skip |= LogError(
1575 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001576 "vkCreateGraphicsPipelines: parameter "
1577 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1578 i, d, vertex_attrib_desc.location);
1579 }
1580 attribute_locations.insert(vertex_attrib_desc.location);
1581
1582 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1583 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(
1585 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001586 "vkCreateGraphicsPipelines: parameter "
1587 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1588 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1589 i, d, vertex_attrib_desc.binding, i);
1590 }
1591
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001592 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001593 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1594 "vkCreateGraphicsPipelines: parameter "
1595 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1596 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1597 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001598 }
1599
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001600 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001601 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1602 "vkCreateGraphicsPipelines: parameter "
1603 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1604 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1605 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606 }
1607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001608 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001609 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1610 "vkCreateGraphicsPipelines: parameter "
1611 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1612 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1613 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001614 }
1615 }
1616 }
1617
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001618 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1619 if (has_control && has_eval) {
1620 if (pCreateInfos[i].pTessellationState == nullptr) {
1621 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1622 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1623 "shader stage and a tessellation evaluation shader stage, "
1624 "pCreateInfos[%d].pTessellationState must not be NULL.",
1625 i, i);
1626 } else {
1627 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1628 skip |= validate_struct_pnext(
1629 "vkCreateGraphicsPipelines",
1630 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1631 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1632 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1633 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001634
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001635 skip |= validate_reserved_flags(
1636 "vkCreateGraphicsPipelines",
1637 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1638 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001639
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001640 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1641 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1642 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1643 "vkCreateGraphicsPipelines: invalid parameter "
1644 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1645 "should be >0 and <=%u.",
1646 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1647 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001648 }
1649 }
1650 }
1651
1652 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1653 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1654 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1655 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001656 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1657 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1658 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1659 "].pViewportState (=NULL) is not a valid pointer.",
1660 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001661 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001662 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1663
1664 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001665 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1666 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1667 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1668 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001669 }
1670
Petr Krausa6103552017-11-16 21:21:58 +01001671 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1672 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001673 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1674 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001675 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1676 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001677 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001678 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001679 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001680 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001681 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001682 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1683 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001684 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001685 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1686 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001687
1688 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001689 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001690 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001691 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001692
Dave Houlton142c4cb2018-10-17 15:04:41 -06001693 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1694 pCreateInfos[i].pViewportState->pNext);
1695 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1696 pCreateInfos[i].pViewportState->pNext);
1697 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1698 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001699 const auto vp_swizzle_struct =
1700 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001701 const auto vp_w_scaling_struct =
1702 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001703
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001704 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001705 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001706 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1707 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1708 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1709 ") is not 1.",
1710 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001711 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001712
Petr Krausa6103552017-11-16 21:21:58 +01001713 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001714 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1715 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1716 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1717 ") is not 1.",
1718 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001719 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001720
Dave Houlton142c4cb2018-10-17 15:04:41 -06001721 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1722 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001723 skip |= LogError(
1724 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1725 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1726 "disabled, but pCreateInfos[%" PRIu32
1727 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1728 ") is not 1.",
1729 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001730 }
1731
Jeff Bolz9af91c52018-09-01 21:53:57 -05001732 if (shading_rate_image_struct &&
1733 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001734 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1735 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1736 "disabled, but pCreateInfos[%" PRIu32
1737 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1738 ") is neither 0 nor 1.",
1739 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001740 }
1741
Petr Krausa6103552017-11-16 21:21:58 +01001742 } else { // multiViewport enabled
1743 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001744 skip |= LogError(
1745 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001746 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001747 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001748 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1749 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1750 "].pViewportState->viewportCount (=%" PRIu32
1751 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1752 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001753 }
Petr Krausa6103552017-11-16 21:21:58 +01001754
1755 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001756 skip |= LogError(
1757 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001758 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001759 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001760 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1761 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1762 "].pViewportState->scissorCount (=%" PRIu32
1763 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1764 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001765 }
1766 }
1767
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001768 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001769 skip |=
1770 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1771 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1772 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1773 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001774 }
1775
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001776 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001777 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1778 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1779 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1780 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1781 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001782 }
1783
Petr Krausa6103552017-11-16 21:21:58 +01001784 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001785 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1786 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1787 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1788 "].pViewportState->viewportCount (=%" PRIu32 ").",
1789 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001790 }
1791
Dave Houlton142c4cb2018-10-17 15:04:41 -06001792 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001793 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001794 skip |=
1795 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1796 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1797 ") must be zero or identical to pCreateInfos[%" PRIu32
1798 "].pViewportState->viewportCount (=%" PRIu32 ").",
1799 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001800 }
1801
Dave Houlton142c4cb2018-10-17 15:04:41 -06001802 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001803 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001804 skip |= LogError(
1805 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001806 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1807 "] "
1808 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1809 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1810 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001811 }
1812
Petr Krausa6103552017-11-16 21:21:58 +01001813 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001814 skip |= LogError(
1815 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001816 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1817 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001818 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1819 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001820 }
1821
1822 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001823 skip |= LogError(
1824 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001825 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1826 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001827 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1828 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001829 }
1830
Jeff Bolz3e71f782018-08-29 23:15:45 -05001831 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001832 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1833 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1834 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001835 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1836 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1837 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1838 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1839 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001840 }
1841
Jeff Bolz9af91c52018-09-01 21:53:57 -05001842 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001843 shading_rate_image_struct->viewportCount > 0 &&
1844 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001845 skip |= LogError(
1846 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001847 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001848 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1849 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001850 i, i);
1851 }
1852
Chris Mayer328d8212018-12-11 14:16:18 +01001853 if (vp_swizzle_struct) {
1854 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001855 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1856 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1857 " does "
1858 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1859 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001860 }
1861 }
1862
Petr Krausb3fcdb42018-01-09 22:09:09 +01001863 // validate the VkViewports
1864 if (!has_dynamic_viewport && viewport_state.pViewports) {
1865 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1866 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001867 const char *fn_name = "vkCreateGraphicsPipelines";
1868 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1869 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1870 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001872 }
1873 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001874
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001875 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001876 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1877 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1878 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1879 "VK_NV_clip_space_w_scaling extension is not enabled.",
1880 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001881 }
1882
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001883 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001884 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1885 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1886 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1887 "VK_EXT_discard_rectangles extension is not enabled.",
1888 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001889 }
1890
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001891 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001892 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1893 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1894 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1895 "VK_EXT_sample_locations extension is not enabled.",
1896 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001897 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001898
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001899 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1901 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1902 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1903 "VK_NV_scissor_exclusive extension is not enabled.",
1904 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001905 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001906
1907 if (coarse_sample_order_struct &&
1908 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1909 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1911 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1912 "] "
1913 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1914 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1915 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001916 }
1917
1918 if (coarse_sample_order_struct) {
1919 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001920 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001921 }
1922 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001923
1924 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1925 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001926 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1927 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1928 "] "
1929 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1930 ") "
1931 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1932 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001933 }
1934 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001935 skip |= LogError(
1936 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001937 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1938 "] "
1939 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1940 i);
1941 }
1942 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001943 }
1944
1945 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001946 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1947 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1948 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1949 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001950 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001951 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1952 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1953 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001954 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001955 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001956 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001957 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001958 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001959 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001960 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001961 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1962 "VUID-VkPipelineMultisampleStateCreateInfo-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].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001967 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968
1969 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1972 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1973
1974 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001975 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001976 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1977 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001978 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001979 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001980
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001981 skip |= validate_flags(
1982 "vkCreateGraphicsPipelines",
1983 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1984 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001985 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1990 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1991
1992 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1995 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1996
1997 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001998 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1999 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2000 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2001 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002 }
John Zulauf7acac592017-11-06 11:15:53 -07002003 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002004 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002005 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2006 "vkCreateGraphicsPipelines(): parameter "
2007 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2008 i);
John Zulauf7acac592017-11-06 11:15:53 -07002009 }
2010 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2011 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2012 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002013 skip |= LogError(
2014 device,
2015
Dave Houlton413a6782018-05-22 13:01:54 -06002016 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002017 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002018 }
2019 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002020
2021 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2022 pCreateInfos[i].pRasterizationState->pNext);
2023
2024 if (line_state) {
2025 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2026 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2027 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2028 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002029 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2030 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2031 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2032 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002033 }
2034 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2035 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002036 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2037 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2038 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2039 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002040 }
2041 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2042 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002043 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2044 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2045 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2046 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002047 }
2048 }
2049 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2050 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002052 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2053 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2054 "range [1,256].",
2055 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002056 }
2057 }
2058 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002059 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002060 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2061 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002062 skip |=
2063 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2064 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2065 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2066 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002067 }
2068 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2069 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002070 skip |=
2071 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2072 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2073 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2074 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002075 }
2076 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2077 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002078 skip |=
2079 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2080 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2081 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2082 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002083 }
2084 if (line_state->stippledLineEnable) {
2085 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2086 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002087 skip |=
2088 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2089 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2090 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2091 "stippledRectangularLines feature.",
2092 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002093 }
2094 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2095 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002096 skip |=
2097 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2098 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2099 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2100 "stippledBresenhamLines feature.",
2101 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002102 }
2103 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2104 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002105 skip |=
2106 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2107 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2108 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2109 "stippledSmoothLines feature.",
2110 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002111 }
2112 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2113 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002114 skip |=
2115 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2116 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2117 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2118 "stippledRectangularLines and strictLines features.",
2119 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002120 }
2121 }
2122 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 }
2124
Petr Krause91f7a12017-12-14 20:57:36 +01002125 bool uses_color_attachment = false;
2126 bool uses_depthstencil_attachment = false;
2127 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002128 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002129 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2130 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002131 const auto &subpasses_uses = subpasses_uses_it->second;
2132 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2133 uses_color_attachment = true;
2134 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2135 uses_depthstencil_attachment = true;
2136 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002137 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002138 }
2139
2140 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002142 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002143 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002144 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002145 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002146
2147 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002148 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002149 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002150 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002151
2152 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002153 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002154 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2155 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2156
2157 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002158 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002159 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2160 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2161
2162 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002163 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002164 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2165 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002166 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002167
2168 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2171 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2172
2173 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2176 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2177
2178 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2181 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002182 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002183
2184 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002185 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2187 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002191 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2193 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002194 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002195
2196 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002197 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2199 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002200 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002201
2202 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002203 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002204 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2205 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002206 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002207
2208 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002209 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002210 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2211 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002212 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213
2214 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2217 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002218 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219
2220 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002221 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002222 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2223 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002224 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225
2226 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002227 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2228 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2229 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2230 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002231 }
2232 }
2233
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002234 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2235 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2236
Petr Krause91f7a12017-12-14 20:57:36 +01002237 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002238 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2239 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2240 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2241 pCreateInfos[i].pColorBlendState,
2242 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2243 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2244
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002246 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002247 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2248 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2249 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002250 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002251 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2252 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253
2254 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002255 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002257 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002258
2259 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002260 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2262 pCreateInfos[i].pColorBlendState->logicOpEnable);
2263
2264 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002265 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2267 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002268 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002269 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270
2271 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2272 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2273 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002274 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2276 ParameterName::IndexVector{i, attachmentIndex}),
2277 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2278
2279 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002280 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2282 ParameterName::IndexVector{i, attachmentIndex}),
2283 "VkBlendFactor", AllVkBlendFactorEnums,
2284 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002285 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002286
2287 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002288 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2290 ParameterName::IndexVector{i, attachmentIndex}),
2291 "VkBlendFactor", AllVkBlendFactorEnums,
2292 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002293 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002294
2295 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002296 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2298 ParameterName::IndexVector{i, attachmentIndex}),
2299 "VkBlendOp", AllVkBlendOpEnums,
2300 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002301 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002302
2303 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002304 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2306 ParameterName::IndexVector{i, attachmentIndex}),
2307 "VkBlendFactor", AllVkBlendFactorEnums,
2308 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002309 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002310
2311 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002312 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2314 ParameterName::IndexVector{i, attachmentIndex}),
2315 "VkBlendFactor", AllVkBlendFactorEnums,
2316 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002317 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318
2319 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002320 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2322 ParameterName::IndexVector{i, attachmentIndex}),
2323 "VkBlendOp", AllVkBlendOpEnums,
2324 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002325 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002326
2327 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002328 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2330 ParameterName::IndexVector{i, attachmentIndex}),
2331 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2332 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002333 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334 }
2335 }
2336
2337 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002338 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2339 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2340 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2341 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
2343
2344 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2345 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2346 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002347 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002349 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2350 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 }
2352 }
2353 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002354
Petr Kraus9752aae2017-11-24 03:05:50 +01002355 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2356 if (pCreateInfos[i].basePipelineIndex != -1) {
2357 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |=
2359 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002360 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002361 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002362 "and pCreateInfos->basePipelineIndex is not -1.",
2363 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364 }
2365 }
2366
Petr Kraus9752aae2017-11-24 03:05:50 +01002367 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2368 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002369 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002370 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002371 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002372 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2373 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002374 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002375 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002376 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002377 skip |=
2378 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2379 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2380 "index into the pCreateInfos array, of size %d.",
2381 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002382 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 }
2384 }
2385
sfricke-samsung898cf222020-05-15 23:10:19 -07002386 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2387 skip |= LogError(
2388 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2389 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2390 i);
2391 }
2392
Petr Kraus9752aae2017-11-24 03:05:50 +01002393 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002394 if (!device_extensions.vk_nv_fill_rectangle) {
2395 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2396 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002397 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2398 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2399 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2400 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002401 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2402 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002403 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2404 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002405 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2406 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2407 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002408 }
2409 } else {
2410 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2411 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2412 (physical_device_features.fillModeNonSolid == false)) {
2413 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002414 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2415 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002416 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2417 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2418 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002419 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002420 }
Petr Kraus299ba622017-11-24 03:09:03 +01002421
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002422 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002423 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002424 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2425 "The line width state is static (pCreateInfos[%" PRIu32
2426 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2427 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2428 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2429 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002430 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002431 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002432 }
2433 }
2434
2435 return skip;
2436}
2437
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002438bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2439 uint32_t createInfoCount,
2440 const VkComputePipelineCreateInfo *pCreateInfos,
2441 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002442 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002443 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002445 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002446 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002447 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002448 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2449 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002450 skip |=
2451 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2452 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2453 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2454 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002455 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002456
2457 // Make sure compute stage is selected
2458 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2460 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2461 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002462 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 return skip;
2465}
2466
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002468 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002469 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002470
2471 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002472 const auto &features = physical_device_features;
2473 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002474
John Zulauf71968502017-10-26 13:51:15 -06002475 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2476 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002477 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2478 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2479 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2480 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002481 }
2482
2483 // Anistropy cannot be enabled in sampler unless enabled as a feature
2484 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002485 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2486 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2487 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002488 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002489 }
John Zulauf71968502017-10-26 13:51:15 -06002490
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002491 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2492 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002493 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2494 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2495 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2496 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002497 }
2498 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2500 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2501 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2502 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002503 }
2504 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2506 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2507 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2508 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002509 }
2510 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2511 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2512 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2513 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002514 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2515 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2516 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2517 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2518 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2519 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002520 }
2521 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2523 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2524 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002525 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002526 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002527 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2528 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2529 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002530 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002531 }
2532
2533 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2534 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002535 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2536 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002537 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2538 if (sampler_reduction != nullptr) {
2539 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2540 skip |= LogError(
2541 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2542 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2543 }
2544 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545 }
2546
2547 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2548 // valid VkBorderColor value
2549 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2550 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2551 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002552 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2553 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554 }
2555
2556 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2557 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002558 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002559 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2560 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2561 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002562 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002563 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2564 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2565 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 }
John Zulauf275805c2017-10-26 15:34:49 -06002567
2568 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002570 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2571 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002572 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2573 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2574 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002575 }
2576 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002577
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002578 // Check for valid Lod range
2579 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002580 skip |=
2581 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2582 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002583 }
2584
2585 // Check mipLodBias to device limit
2586 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002587 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2588 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2589 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002590 }
2591
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002592 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2593 if (sampler_conversion != nullptr) {
2594 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2595 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2596 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2597 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002598 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002599 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002600 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2601 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2602 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2603 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2604 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2605 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2606 }
2607 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002608
2609 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2610 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2611 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2612 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2613 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2614 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2615 }
2616 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2617 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2618 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2619 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2620 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2621 }
2622 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2623 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2624 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2625 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2626 pCreateInfo->minLod, pCreateInfo->maxLod);
2627 }
2628 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2629 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2630 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2631 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2632 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2633 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2634 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2635 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2636 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2637 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2638 }
2639 if (pCreateInfo->anisotropyEnable) {
2640 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2641 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2642 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2643 }
2644 if (pCreateInfo->compareEnable) {
2645 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2646 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2647 "pCreateInfo->compareEnable must be VK_FALSE");
2648 }
2649 if (pCreateInfo->unnormalizedCoordinates) {
2650 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2651 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2652 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2653 }
2654 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 }
2656
Tony-LunarG7337b312020-04-15 16:40:25 -06002657 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2658 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2659 if (!device_extensions.vk_ext_custom_border_color) {
2660 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2661 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2662 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2663 }
2664 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2665 if (!custom_create_info) {
2666 skip |=
2667 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2668 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2669 "struct in pNext chain.\n",
2670 string_VkBorderColor(pCreateInfo->borderColor));
2671 } else {
2672 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2673 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2674 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2675 !FormatIsSampledFloat(custom_create_info->format)))) {
2676 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2677 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2678 "whose type does not match\n",
2679 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2680 ;
2681 }
2682 }
2683 }
2684
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 return skip;
2686}
2687
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002688bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2689 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2690 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002691 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002693
2694 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2695 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2696 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2697 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002698 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2699 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2700 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2701 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2702 ++descriptor_index) {
2703 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002704 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002705 "vkCreateDescriptorSetLayout: required parameter "
2706 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2707 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002708 }
2709 }
2710 }
2711
2712 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2713 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2714 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002715 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2716 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2717 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2718 "values.",
2719 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002720 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002721
2722 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2723 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2724 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2725 skip |=
2726 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2727 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2728 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2729 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2730 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2731 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002732 }
2733 }
2734 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002735 return skip;
2736}
2737
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002738bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2739 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002740 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002741 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2742 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2743 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002744 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2745 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746}
2747
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002748bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2749 const VkWriteDescriptorSet *pDescriptorWrites,
2750 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002751 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002752
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002753 if (pDescriptorWrites != NULL) {
2754 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2755 // descriptorCount must be greater than 0
2756 if (pDescriptorWrites[i].descriptorCount == 0) {
2757 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002758 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2759 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 }
2761
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002762 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2763 if (validateDstSet) {
2764 // dstSet must be a valid VkDescriptorSet handle
2765 skip |= validate_required_handle(vkCallingFunction,
2766 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2767 pDescriptorWrites[i].dstSet);
2768 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002769
2770 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2771 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2772 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2773 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2774 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2775 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2776 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002777 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2778 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002779 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002780 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2781 "%s(): if pDescriptorWrites[%d].descriptorType is "
2782 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2783 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2784 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2785 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002786 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2787 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002788 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2789 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002790 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2791 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002792 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002793 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2794 ParameterName::IndexVector{i, descriptor_index}),
2795 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002796 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 }
2798 }
2799 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2800 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2801 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2802 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2803 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2804 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2805 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002806 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002807 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002808 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2809 "%s(): if pDescriptorWrites[%d].descriptorType is "
2810 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2811 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2812 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2813 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002814 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002815 const auto *robustness2_features =
2816 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2817 if (robustness2_features && robustness2_features->nullDescriptor) {
2818 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2819 ++descriptorIndex) {
2820 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2821 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2822 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2823 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2824 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2825 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2826 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2827 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2828 }
2829 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 }
2831 }
2832 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2833 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002834 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 }
2836
2837 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2838 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002839 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2841 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2842 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002843 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002844 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2845 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2846 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2847 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848 }
2849 }
2850 }
2851 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2852 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002853 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002854 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2855 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2856 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002857 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002858 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2859 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2860 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2861 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 }
2863 }
2864 }
2865 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002866 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2867 // or VkWriteDescriptorSetInlineUniformBlockEX
2868 if (pDescriptorWrites[i].pNext) {
2869 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2870 const auto *pNext_struct =
2871 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2872 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2873 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2874 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2875 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2876 "accelerationStructureCount %d member equals descriptorCount %d.",
2877 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2878 pDescriptorWrites[i].descriptorCount);
2879 }
2880 // further checks only if we have right structtype
2881 if (pNext_struct) {
2882 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2883 skip |= LogError(
2884 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2885 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2886 ".",
2887 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2888 }
2889 if (pNext_struct->accelerationStructureCount == 0) {
2890 skip |= LogError(
2891 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2892 "%s(): accelerationStructureCount must be greater than 0 .");
2893 }
2894 }
2895 }
2896 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898 }
2899 return skip;
2900}
2901
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002902bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2903 const VkWriteDescriptorSet *pDescriptorWrites,
2904 uint32_t descriptorCopyCount,
2905 const VkCopyDescriptorSet *pDescriptorCopies) const {
2906 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2907}
2908
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002909bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002910 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002911 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002912 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2913}
2914
2915bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002916 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002917 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002918 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2919}
2920
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002921bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2922 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002923 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002925
2926 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2927 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2928 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002929 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2930 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 return skip;
2932}
2933
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002934bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002935 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002936 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002937
2938 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2939 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2941
Petr Krause7bb9e82019-08-11 21:34:43 +02002942 // Implicit VUs
2943 // validate only sType here; pointer has to be validated in core_validation
2944 const bool kNotRequired = false;
2945 const char *kNoVUID = nullptr;
2946 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2947 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2948 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002949
Petr Krause7bb9e82019-08-11 21:34:43 +02002950 if (pInfo) {
2951 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2952 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2953 skip |= validate_struct_pnext(
2954 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2955 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002956 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2957 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958
Petr Krause7bb9e82019-08-11 21:34:43 +02002959 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002960
Petr Krause7bb9e82019-08-11 21:34:43 +02002961 // Explicit VUs
2962 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002963 skip |= LogError(
2964 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002965 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2966 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002967 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002968
2969 if (physical_device_features.inheritedQueries) {
2970 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002971 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002972 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002973 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002974 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002975 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002976 }
2977
2978 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002979 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002980 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002981 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002982 } else { // !pipelineStatisticsQuery
2983 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2984 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002985 }
Petr Kraus139757b2019-08-15 17:19:33 +02002986
2987 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2988 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002989 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002990 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2991 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002992 skip |= LogError(
2993 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002994 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2995 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2996 }
2997 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 }
2999
3000 return skip;
3001}
3002
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003003bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003004 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003006
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003007 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003008 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003009 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3010 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3011 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003012 }
3013 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003014 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3015 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3016 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003017 }
3018 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003019 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003020 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003021 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3022 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3023 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3024 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003025 }
3026 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003027
3028 if (pViewports) {
3029 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3030 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003031 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003032 skip |= manual_PreCallValidateViewport(
3033 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003034 }
3035 }
3036
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 return skip;
3038}
3039
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003040bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003041 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003042 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003044 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003045 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003046 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3047 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3048 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003049 }
3050 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003051 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3052 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3053 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003054 }
3055 } else { // multiViewport enabled
3056 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003057 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003058 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3059 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3060 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3061 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062 }
3063 }
3064
Petr Kraus6260f0a2018-02-27 21:15:55 +01003065 if (pScissors) {
3066 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3067 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003068
Petr Kraus6260f0a2018-02-27 21:15:55 +01003069 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003070 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3071 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3072 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003073 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003074
Petr Kraus6260f0a2018-02-27 21:15:55 +01003075 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003076 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3077 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3078 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003079 }
3080
3081 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3082 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003083 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3084 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3085 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3086 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003087 }
3088
3089 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3090 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003091 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3092 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3093 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3094 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003095 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003096 }
3097 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003098
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 return skip;
3100}
3101
Jeff Bolz5c801d12019-10-09 10:38:45 -05003102bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003103 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003104
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003105 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003106 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3107 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003108 }
3109
3110 return skip;
3111}
3112
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003113bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003114 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003116 if (vertexCount == 0) {
3117 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3118 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003119 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 }
3121
3122 if (instanceCount == 0) {
3123 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3124 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003125 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003126 }
3127 return skip;
3128}
3129
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003130bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003131 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003133
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003134 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003135 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3136 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 }
3138 return skip;
3139}
3140
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003141bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003142 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003144 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003145 skip |=
3146 LogError(device, kVUID_PVError_DeviceFeature,
3147 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
3149 return skip;
3150}
3151
sfricke-samsungf692b972020-05-02 08:00:45 -07003152bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3153 VkDeviceSize countBufferOffset, bool khr) const {
3154 bool skip = false;
3155 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3156 if (offset & 3) {
3157 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3158 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3159 }
3160
3161 if (countBufferOffset & 3) {
3162 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3163 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3164 countBufferOffset);
3165 }
3166 return skip;
3167}
3168
3169bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3170 VkDeviceSize offset, VkBuffer countBuffer,
3171 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3172 uint32_t stride) const {
3173 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3174}
3175
3176bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3177 VkDeviceSize offset, VkBuffer countBuffer,
3178 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3179 uint32_t stride) const {
3180 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3181}
3182
3183bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3184 VkDeviceSize countBufferOffset, bool khr) const {
3185 bool skip = false;
3186 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3187 if (offset & 3) {
3188 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3189 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3190 }
3191
3192 if (countBufferOffset & 3) {
3193 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3194 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3195 countBufferOffset);
3196 }
3197 return skip;
3198}
3199
3200bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3201 VkDeviceSize offset, VkBuffer countBuffer,
3202 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3203 uint32_t stride) const {
3204 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3205}
3206
3207bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3208 VkDeviceSize offset, VkBuffer countBuffer,
3209 VkDeviceSize countBufferOffset,
3210 uint32_t maxDrawCount, uint32_t stride) const {
3211 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3212}
3213
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003214bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3215 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003216 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003217 bool skip = false;
3218 for (uint32_t rect = 0; rect < rectCount; rect++) {
3219 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003220 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3221 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003222 }
sfricke-samsung10867682020-04-25 02:20:39 -07003223 if (pRects[rect].rect.extent.width == 0) {
3224 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3225 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3226 }
3227 if (pRects[rect].rect.extent.height == 0) {
3228 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3229 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3230 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003231 }
3232 return skip;
3233}
3234
Andrew Fobel3abeb992020-01-20 16:33:22 -05003235bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3236 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3237 VkImageFormatProperties2 *pImageFormatProperties,
3238 const char *apiName) const {
3239 bool skip = false;
3240
3241 if (pImageFormatInfo != nullptr) {
3242 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3243 if (image_stencil_struct != nullptr) {
3244 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3245 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3246 // No flags other than the legal attachment bits may be set
3247 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3248 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003249 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3250 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3251 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3252 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3253 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003254 }
3255 }
3256 }
3257 }
3258
3259 return skip;
3260}
3261
3262bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3263 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3264 VkImageFormatProperties2 *pImageFormatProperties) const {
3265 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3266 "vkGetPhysicalDeviceImageFormatProperties2");
3267}
3268
3269bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3270 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3271 VkImageFormatProperties2 *pImageFormatProperties) const {
3272 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3273 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3274}
3275
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003276bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3277 VkImageLayout srcImageLayout, VkImage dstImage,
3278 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003279 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003280 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281
Dave Houltonf5217612018-02-02 16:18:52 -07003282 VkImageAspectFlags legal_aspect_flags =
3283 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 -07003284 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003285 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3286 }
3287
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003288 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003289 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003290 skip |= LogError(
3291 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003292 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293 }
Dave Houltonf5217612018-02-02 16:18:52 -07003294 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003295 skip |= LogError(
3296 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003297 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 }
3299 }
3300 return skip;
3301}
3302
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003303bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3304 VkImageLayout srcImageLayout, VkImage dstImage,
3305 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003306 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003307 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003308
Dave Houltonf5217612018-02-02 16:18:52 -07003309 VkImageAspectFlags legal_aspect_flags =
3310 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 -07003311 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003312 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3313 }
3314
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003316 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(
3318 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3320 }
Dave Houltonf5217612018-02-02 16:18:52 -07003321 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(
3323 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003324 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3325 }
3326 }
3327 return skip;
3328}
3329
sfricke-samsung3999ef62020-02-09 17:05:59 -08003330bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3331 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3332 bool skip = false;
3333
3334 if (pRegions != nullptr) {
3335 for (uint32_t i = 0; i < regionCount; i++) {
3336 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003337 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3338 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003339 }
3340 }
3341 }
3342 return skip;
3343}
3344
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003345bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3346 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003347 uint32_t regionCount,
3348 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003349 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350
Dave Houltonf5217612018-02-02 16:18:52 -07003351 VkImageAspectFlags legal_aspect_flags =
3352 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 -07003353 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003354 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3355 }
3356
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003357 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003358 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003359 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3360 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3361 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003362 }
3363 }
3364 return skip;
3365}
3366
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003367bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3368 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003369 uint32_t regionCount,
3370 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003372
Dave Houltonf5217612018-02-02 16:18:52 -07003373 VkImageAspectFlags legal_aspect_flags =
3374 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 -07003375 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003376 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3377 }
3378
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003379 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003380 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003381 skip |= LogError(
3382 device, kVUID_PVError_UnrecognizedValue,
3383 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3384 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003385 }
3386 }
3387 return skip;
3388}
3389
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003390bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003391 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3392 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394
3395 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3397 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3398 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003399 }
3400
3401 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003402 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3403 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3404 "), must be greater than zero and less than or equal to 65536.",
3405 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003406 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003407 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3408 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3409 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003410 }
3411 return skip;
3412}
3413
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003414bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003415 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003416 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417
3418 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003419 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3420 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3421 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422 }
3423
3424 if (size != VK_WHOLE_SIZE) {
3425 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003426 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003427 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3428 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003430 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3431 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 }
3433 }
3434 return skip;
3435}
3436
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003437bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003438 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003439 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441
3442 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003443 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3444 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3445 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3446 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003447 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3448 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3449 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450 }
3451
3452 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3453 // queueFamilyIndexCount uint32_t values
3454 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003455 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3456 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3457 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3458 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003459 }
3460 }
3461
Dave Houlton413a6782018-05-22 13:01:54 -06003462 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003463 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464 }
3465
3466 return skip;
3467}
3468
Jeff Bolz5c801d12019-10-09 10:38:45 -05003469bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003470 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471
3472 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003473 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3474 if (present_regions) {
3475 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003476 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003477 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3478 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003479 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3480 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3481 "extension swapchainCount is %i. These values must be equal.",
3482 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003483 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003484 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003485 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3486 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003487 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3488 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3489 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003490 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003491 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003492 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003493 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003494 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 }
3496 }
3497
3498 return skip;
3499}
3500
3501#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003502bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3503 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3504 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003505 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003506 bool skip = false;
3507
3508 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3510 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003511 }
3512
3513 return skip;
3514}
3515#endif // VK_USE_PLATFORM_WIN32_KHR
3516
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003517bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003518 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003519 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003520 bool skip = false;
3521
3522 if (pCreateInfo) {
3523 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003524 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3525 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003526 }
3527
3528 if (pCreateInfo->pPoolSizes) {
3529 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3530 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003531 skip |= LogError(
3532 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003533 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003534 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003535 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3536 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003537 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3538 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3539 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3540 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3541 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003542 }
Petr Krausc8655be2017-09-27 18:56:51 +02003543 }
3544 }
3545 }
3546
3547 return skip;
3548}
3549
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003550bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003551 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003552 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003553
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003554 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003555 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003556 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3557 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3558 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003559 }
3560
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003561 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003562 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003563 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3564 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3565 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003566 }
3567
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003568 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003569 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003570 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3571 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3572 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003573 }
3574
3575 return skip;
3576}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003577
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003578bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003579 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003580 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003581
3582 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003583 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3584 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003585 }
3586 return skip;
3587}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003588
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003589bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3590 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003591 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003592 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003593
3594 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003595 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003596 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3598 "vkCmdDispatch(): baseGroupX (%" PRIu32
3599 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3600 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003601 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003602 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3603 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3604 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3605 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003606 }
3607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003608 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003609 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3611 "vkCmdDispatch(): baseGroupY (%" PRIu32
3612 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3613 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003614 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003615 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3616 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3617 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3618 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003619 }
3620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003621 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003622 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003623 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3624 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3625 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3626 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003627 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003628 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3629 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3630 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3631 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003632 }
3633
3634 return skip;
3635}
3636
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003637bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3638 VkPipelineBindPoint pipelineBindPoint,
3639 VkPipelineLayout layout, uint32_t set,
3640 uint32_t descriptorWriteCount,
3641 const VkWriteDescriptorSet *pDescriptorWrites) const {
3642 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3643}
3644
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003645bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3646 uint32_t firstExclusiveScissor,
3647 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003648 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003649 bool skip = false;
3650
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003651 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003652 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003653 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003654 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3655 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3656 ") is not 0.",
3657 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003658 }
3659 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003660 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003661 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3662 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3663 ") is not 1.",
3664 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003665 }
3666 } else { // multiViewport enabled
3667 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003668 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003669 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3670 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3671 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3672 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003673 }
3674 }
3675
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003676 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003677 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3678 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3679 ") must be less than maxViewports (=%" PRIu32 ").",
3680 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003681 }
3682
3683 if (pExclusiveScissors) {
3684 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3685 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3686
3687 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003688 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3689 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3690 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003691 }
3692
3693 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003694 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3695 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3696 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003697 }
3698
3699 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3700 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003701 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3702 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3703 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3704 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003705 }
3706
3707 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3708 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003709 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3710 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3711 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3712 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003713 }
3714 }
3715 }
3716
3717 return skip;
3718}
3719
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003720bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3721 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003722 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003723 bool skip = false;
3724 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003725 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3726 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3727 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003728 } else {
3729 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3730 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003731 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3732 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3733 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3734 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003735 }
3736 }
3737
3738 return skip;
3739}
3740
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003741bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3742 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003743 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003744 bool skip = false;
3745
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003746 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003747 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003748 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3750 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3751 ") is not 0.",
3752 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003753 }
3754 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003755 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3757 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3758 ") is not 1.",
3759 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003760 }
3761 }
3762
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003763 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003764 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3765 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3766 ") must be less than maxViewports (=%" PRIu32 ").",
3767 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003768 }
3769
3770 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003771 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003772 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3773 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3774 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3775 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003776 }
3777
3778 return skip;
3779}
3780
Jeff Bolz5c801d12019-10-09 10:38:45 -05003781bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3782 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3783 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003784 bool skip = false;
3785
Dave Houlton142c4cb2018-10-17 15:04:41 -06003786 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003787 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3788 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3789 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003790 }
3791
3792 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003793 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003794 }
3795
3796 return skip;
3797}
3798
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003799bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003800 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003801 bool skip = false;
3802
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003803 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003804 skip |= LogError(
3805 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003806 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3807 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003808 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003809 }
3810
3811 return skip;
3812}
3813
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003814bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3815 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003816 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003817 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003818 static const int condition_multiples = 0b0011;
3819 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= LogError(
3821 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003822 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003823 }
Lockee1c22882019-06-10 16:02:54 -06003824 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003825 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3826 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3827 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3828 stride);
Lockee1c22882019-06-10 16:02:54 -06003829 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003830 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003831 skip |= LogError(
3832 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3833 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003834 }
3835
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003836 return skip;
3837}
3838
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003839bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3840 VkDeviceSize offset, VkBuffer countBuffer,
3841 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003842 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003843 bool skip = false;
3844
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003845 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003846 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3847 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3848 "), is not a multiple of 4.",
3849 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003850 }
3851
3852 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003853 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3854 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3855 "), is not a multiple of 4.",
3856 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003857 }
3858
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003859 return skip;
3860}
3861
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003862bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003863 const VkAllocationCallbacks *pAllocator,
3864 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003865 bool skip = false;
3866
3867 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3868 if (pCreateInfo != nullptr) {
3869 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3870 // VkQueryPipelineStatisticFlagBits values
3871 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3872 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003873 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3874 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3875 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3876 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003877 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003878 if (pCreateInfo->queryCount == 0) {
3879 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3880 "vkCreateQueryPool(): queryCount must be greater than zero.");
3881 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003882 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003883 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003884}
3885
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003886bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3887 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003888 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003889 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3890 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003891}
3892
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003893void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003894 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3895 VkResult result) {
3896 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003897 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003898}
3899
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003900void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003901 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3902 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003903 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003904 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003905 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003906}
3907
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003908void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3909 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003910 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003911 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003912 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003913}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003914
3915bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003916 const VkAllocationCallbacks *pAllocator,
3917 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003918 bool skip = false;
3919
3920 if (pAllocateInfo) {
3921 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3922 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003923 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3924 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003925 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003926
3927 VkMemoryAllocateFlags flags = 0;
3928 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3929 if (flags_info) {
3930 flags = flags_info->flags;
3931 }
3932
3933 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3934 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3935 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003936 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3937 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3938 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003939 }
3940
3941#ifdef VK_USE_PLATFORM_WIN32_KHR
3942 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3943#endif
3944 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3945 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3946#ifdef VK_USE_PLATFORM_ANDROID_KHR
3947 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3948#endif
3949
3950 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003951 skip |= LogError(
3952 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003953 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3954 }
3955 if (
3956#ifdef VK_USE_PLATFORM_WIN32_KHR
3957 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3958#endif
3959 (import_memory_fd && import_memory_fd->handleType) ||
3960#ifdef VK_USE_PLATFORM_ANDROID_KHR
3961 (import_memory_ahb && import_memory_ahb->buffer) ||
3962#endif
3963 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003964 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3965 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003966 }
3967 }
3968
3969 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003970 VkBool32 capture_replay = false;
3971 VkBool32 buffer_device_address = false;
3972 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3973 if (vulkan_12_features) {
3974 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3975 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3976 } else {
3977 const auto *bda_features =
3978 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3979 if (bda_features) {
3980 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3981 buffer_device_address = bda_features->bufferDeviceAddress;
3982 }
3983 }
3984 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003985 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3986 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3987 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003988 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003989 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003990 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3991 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003992 }
3993 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003994 }
3995 return skip;
3996}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003997
Jason Macnak192fa0e2019-07-26 15:07:16 -07003998bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003999 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004000 bool skip = false;
4001
4002 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4003 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4004 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004005 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004006 } else {
4007 uint32_t vertex_component_size = 0;
4008 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4009 vertex_component_size = 4;
4010 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4011 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4012 vertex_component_size = 2;
4013 }
4014 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004015 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004016 }
4017 }
4018
4019 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4020 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004021 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004022 } else {
4023 uint32_t index_element_size = 0;
4024 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4025 index_element_size = 4;
4026 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4027 index_element_size = 2;
4028 }
4029 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004030 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004031 }
4032 }
4033 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4034 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004035 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004036 }
4037 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004038 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004039 }
4040 }
4041
4042 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004043 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004044 }
4045
4046 return skip;
4047}
4048
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004049bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4050 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004051 bool skip = false;
4052
4053 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004054 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004055 }
4056 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004057 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004058 }
4059
4060 return skip;
4061}
4062
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004063bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4064 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004065 bool skip = false;
4066 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004067 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004068 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004069 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004070 }
4071 return skip;
4072}
4073
4074bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004075 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07004076 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004077 bool skip = false;
4078 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004079 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4080 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4081 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004082 }
4083 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004084 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4085 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4086 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004087 }
4088 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4089 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004090 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4091 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4092 "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 -07004093 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004094 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
4096 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4097 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004098 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004099 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004100 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4101 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4102 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004103 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004104 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004105 uint64_t total_triangle_count = 0;
4106 for (uint32_t i = 0; i < info.geometryCount; i++) {
4107 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004108
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004109 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004110
Jason Macnak5c954952019-07-09 15:46:12 -07004111 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4112 continue;
4113 }
4114 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4115 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004116 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004117 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4118 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4119 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004120 }
4121 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004122 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4123 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4124 for (uint32_t i = 1; i < info.geometryCount; i++) {
4125 const VkGeometryNV &geometry = info.pGeometries[i];
4126 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004127 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004128 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4129 "info.pGeometries[0].geometryType.",
4130 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004131 }
4132 }
4133 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004134 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4135 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4136 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4137 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4138 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4139 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4140 }
4141 }
4142 skip |=
4143 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
4144 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07004145 return skip;
4146}
4147
Ricardo Garciaa4935972019-02-21 17:43:18 +01004148bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4149 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004150 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004151 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004152 if (pCreateInfo) {
4153 if ((pCreateInfo->compactedSize != 0) &&
4154 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004155 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4156 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4157 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4158 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004159 }
Jason Macnak5c954952019-07-09 15:46:12 -07004160
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004161 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07004162 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01004163 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004164 return skip;
4165}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004166
Jeff Bolz5c801d12019-10-09 10:38:45 -05004167bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4168 const VkAccelerationStructureInfoNV *pInfo,
4169 VkBuffer instanceData, VkDeviceSize instanceOffset,
4170 VkBool32 update, VkAccelerationStructureNV dst,
4171 VkAccelerationStructureNV src, VkBuffer scratch,
4172 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004173 bool skip = false;
4174
4175 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004176 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004177 }
4178
4179 return skip;
4180}
4181
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004182bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4183 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4184 VkAccelerationStructureKHR *pAccelerationStructure) const {
4185 bool skip = false;
4186
4187 if (pCreateInfo) {
4188 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4189 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4190 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4191 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4192 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4193 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4194 i);
4195 }
4196 }
4197
4198 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4199 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4200 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4201 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4202 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4203 i);
4204 }
4205 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004206 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4207 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4208 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4209 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4210 skip |= LogError(
4211 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4212 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4213 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4214 }
4215 }
4216 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4217 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4218 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4219 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4220 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4221 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4222 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4223 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4224 }
4225 }
4226 }
4227
4228 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4229 pCreateInfo->maxGeometryCount != 1) {
4230 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4231 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4232 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004233 }
4234
4235 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4236 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4237 skip |= LogError(
4238 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4239 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4240 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4241 }
4242
4243 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4244 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4245 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4246 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4247 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4248 }
4249
4250 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4251 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4252 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4253 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4254 if (geometry_type != first_geometry_type) {
4255 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4256 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4257 "pGeometryInfos[0].geometryType.",
4258 i);
4259 }
4260 }
4261 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004262 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4263 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4264 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4265 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4266 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4267 "maxGeometryCount %d.",
4268 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4269 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004270 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004271 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4272 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4273 if (pCreateInfo->deviceAddress != 0) {
4274 skip |=
4275 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4276 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4277 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4278 }
4279 }
sourav parmar83c31b12020-05-06 12:30:54 -07004280 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4281 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4282 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4283 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004284 return skip;
4285}
4286
Jason Macnak5c954952019-07-09 15:46:12 -07004287bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4288 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004289 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004290 bool skip = false;
4291 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004292 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4293 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004294 }
4295 return skip;
4296}
4297
Peter Chen85366392019-05-14 15:20:11 -04004298bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4299 uint32_t createInfoCount,
4300 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4301 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004302 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004303 bool skip = false;
4304
4305 for (uint32_t i = 0; i < createInfoCount; i++) {
4306 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4307 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004308 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004309 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4310 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4311 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4312 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004313 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004314
4315 const auto *pipeline_cache_contol_features =
4316 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4317 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4318 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4319 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4320 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4321 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4322 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4323 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4324 }
4325 }
4326
sourav parmarf4a78252020-04-10 13:04:21 -07004327 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4328 skip |=
4329 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4330 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4331 }
4332 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4333 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4334 skip |=
4335 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4336 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4337 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4338 }
4339 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4340 if (pCreateInfos[i].basePipelineIndex != -1) {
4341 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4342 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4343 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4344 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4345 "and pCreateInfos->basePipelineIndex is not -1.");
4346 }
4347 }
4348 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4349 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4350 skip |=
4351 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4352 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4353 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4354 "commands pCreateInfos parameter.");
4355 }
4356 } else {
4357 if (pCreateInfos[i].basePipelineIndex != -1) {
4358 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4359 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4360 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4361 }
4362 }
4363 }
4364 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4365 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4366 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4367 }
4368 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4369 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4370 "vkCreateRayTracingPipelinesNV: flags must not include "
4371 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4372 }
4373 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4374 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4375 "vkCreateRayTracingPipelinesNV: flags must not include "
4376 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4377 }
4378 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4379 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4380 "vkCreateRayTracingPipelinesNV: flags must not include "
4381 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4382 }
4383 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4384 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4385 "vkCreateRayTracingPipelinesNV: flags must not include "
4386 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4387 }
4388 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4389 skip |= LogError(
4390 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4391 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4392 }
4393 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4394 skip |= LogError(
4395 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4396 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4397 }
Peter Chen85366392019-05-14 15:20:11 -04004398 }
4399
4400 return skip;
4401}
4402
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004403bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4404 uint32_t createInfoCount,
4405 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4406 const VkAllocationCallbacks *pAllocator,
4407 VkPipeline *pPipelines) const {
4408 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004409 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4410 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4411 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4412 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4413 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004414 for (uint32_t i = 0; i < createInfoCount; i++) {
4415 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4416 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4417 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4418 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4419 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4420 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4421 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4422 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004423 const auto *pipeline_cache_contol_features =
4424 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4425 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4426 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4427 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4428 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4429 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4430 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4431 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4432 }
4433 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004434 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4435 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4436 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4437 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4438 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4439 }
4440 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4441 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4442 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4443 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4444 }
4445 }
4446
sourav parmarf4a78252020-04-10 13:04:21 -07004447 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4448 skip |=
4449 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4450 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4451 }
4452 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4453 if (pCreateInfos[i].pLibraryInterface == NULL)
4454 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4455 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4456 }
4457 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4458 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4459 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4460 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4461 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4462 skip |= LogError(
4463 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4464 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4465 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4466 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4467 "must not be VK_SHADER_UNUSED_KHR");
4468 }
4469 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4470 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4471 skip |= LogError(
4472 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4473 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4474 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4475 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4476 "element must not be VK_SHADER_UNUSED_KHR");
4477 }
4478 }
4479 }
4480 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4481 if (pCreateInfos[i].basePipelineIndex != -1) {
4482 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4483 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4484 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4485 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4486 "and pCreateInfos->basePipelineIndex is not -1.");
4487 }
4488 }
4489 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4490 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4491 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4492 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4493 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4494 "commands pCreateInfos parameter %d.",
4495 pCreateInfos[i].basePipelineIndex, createInfoCount);
4496 }
4497 } else {
4498 if (pCreateInfos[i].basePipelineIndex != -1) {
4499 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4500 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4501 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4502 }
4503 }
4504 }
4505 if (pCreateInfos[i].libraries.libraryCount == 0) {
4506 if (pCreateInfos[i].stageCount == 0) {
4507 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4508 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4509 }
4510 if (pCreateInfos[i].groupCount == 0) {
4511 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4512 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4513 }
4514 } else {
4515 if (pCreateInfos[i].pLibraryInterface == NULL) {
4516 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4517 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4518 }
4519 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004520 }
4521
4522 return skip;
4523}
4524
Mike Schuchardt21638df2019-03-16 10:52:02 -07004525#ifdef VK_USE_PLATFORM_WIN32_KHR
4526bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4527 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004528 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004529 bool skip = false;
4530 if (!device_extensions.vk_khr_swapchain)
4531 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4532 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4533 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4534 if (!device_extensions.vk_khr_surface)
4535 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4536 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4537 skip |=
4538 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4539 if (!device_extensions.vk_ext_full_screen_exclusive)
4540 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4541 skip |= validate_struct_type(
4542 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4543 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4544 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4545 if (pSurfaceInfo != NULL) {
4546 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4547 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4548 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4549
4550 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4551 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4552 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4553 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004554 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4555 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004556
4557 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4558 }
4559 return skip;
4560}
4561#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004562
4563bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4564 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004565 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004566 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4567 bool skip = false;
4568 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4569 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4570 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4571 }
4572 return skip;
4573}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004574
4575bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004576 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004577 bool skip = false;
4578
4579 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004580 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4581 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004582 }
4583
4584 return skip;
4585}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004586
4587bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004588 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004589 bool skip = false;
4590
4591 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004592 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4593 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004594 }
4595
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004596 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004597 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004598 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4599 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004600 }
4601
4602 return skip;
4603}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004604
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004605bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4606 uint32_t bindingCount, const VkBuffer *pBuffers,
4607 const VkDeviceSize *pOffsets) const {
4608 bool skip = false;
4609 if (firstBinding > device_limits.maxVertexInputBindings) {
4610 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4611 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4612 device_limits.maxVertexInputBindings);
4613 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4614 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4615 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4616 "maxVertexInputBindings (%u)",
4617 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4618 }
4619
Jeff Bolz165818a2020-05-08 11:19:03 -05004620 for (uint32_t i = 0; i < bindingCount; ++i) {
4621 if (pBuffers[i] == VK_NULL_HANDLE) {
4622 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4623 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4624 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4625 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4626 } else {
4627 if (pOffsets[i] != 0) {
4628 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4629 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4630 }
4631 }
4632 }
4633 }
4634
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004635 return skip;
4636}
4637
Mark Lobodzinski84988402019-09-11 15:27:30 -06004638bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004639 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004640 bool skip = false;
4641 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004642 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4643 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004644 }
4645 return skip;
4646}
4647
4648bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004649 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004650 bool skip = false;
4651 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004652 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4653 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004654 }
4655 return skip;
4656}
Petr Kraus3d720392019-11-13 02:52:39 +01004657
4658bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4659 VkSemaphore semaphore, VkFence fence,
4660 uint32_t *pImageIndex) const {
4661 bool skip = false;
4662
4663 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004664 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4665 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004666 }
4667
4668 return skip;
4669}
4670
4671bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4672 uint32_t *pImageIndex) const {
4673 bool skip = false;
4674
4675 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004676 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4677 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004678 }
4679
4680 return skip;
4681}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004682
4683bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4684 uint32_t firstInstance, VkBuffer counterBuffer,
4685 VkDeviceSize counterBufferOffset,
4686 uint32_t counterOffset, uint32_t vertexStride) const {
4687 bool skip = false;
4688
4689 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004690 skip |= LogError(
4691 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004692 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4693 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4694 }
4695
4696 return skip;
4697}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004698
4699bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4700 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4701 const VkAllocationCallbacks *pAllocator,
4702 VkSamplerYcbcrConversion *pYcbcrConversion,
4703 const char *apiName) const {
4704 bool skip = false;
4705
4706 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004707 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004708 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004709 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4710 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004711 }
4712 return skip;
4713}
4714
4715bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4716 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4717 const VkAllocationCallbacks *pAllocator,
4718 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4719 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4720 "vkCreateSamplerYcbcrConversion");
4721}
4722
4723bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4724 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4725 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4726 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4727 "vkCreateSamplerYcbcrConversionKHR");
4728}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004729
4730bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4731 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4732 bool skip = false;
4733 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4734 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4735
4736 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004737 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4738 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4739 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4740 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4741 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004742 }
4743 return skip;
4744}
sourav parmara96ab1a2020-04-25 16:28:23 -07004745
4746bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4747 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4748 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004749 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4750 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4751 skip |=
4752 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4753 "vkCopyAccelerationStructureToMemoryKHR: the "
4754 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4755 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004756 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4757 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4758 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4759 }
4760 return skip;
4761}
4762
4763bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4764 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4765 bool skip = false;
4766 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4767 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4768 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4769 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4770 }
sourav parmar83c31b12020-05-06 12:30:54 -07004771 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4772 if (pNext_struct) {
4773 skip |= LogError(
4774 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4775 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4776 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4777 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004778 return skip;
4779}
4780
4781bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4782 const char *api_name) const {
4783 bool skip = false;
4784 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4785 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4786 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4787 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4788 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4789 api_name);
4790 }
4791 return skip;
4792}
4793
4794bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4795 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4796 bool skip = false;
4797 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004798 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4799 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4800 skip |= LogError(
4801 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4802 "vkCopyAccelerationStructureKHR(): the "
4803 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4804 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004805 return skip;
4806}
4807
4808bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4809 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4810 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004811 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4812 if (pNext_struct) {
4813 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4814 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4815 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4816 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004817 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4818 return skip;
4819}
4820
4821bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004822 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004823 bool skip = false;
4824 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004825 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004826 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
4827 : "VUID-vkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07004828 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4829 }
4830 return skip;
4831}
4832
4833bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4834 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4835 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004836 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
4837 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4838 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4839 skip |=
4840 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
4841 "vkCopyMemoryToAccelerationStructureKHR() :the "
4842 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4843 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004844 return skip;
4845}
4846bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4847 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4848 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004849 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
4850 return skip;
4851}
4852bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
4853 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4854 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4855 bool skip = false;
4856 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4857 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4858 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4859 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
4860 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4861 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4862 }
4863 return skip;
4864}
4865bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
4866 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4867 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
4868 bool skip = false;
4869 if (dataSize < accelerationStructureCount * stride) {
4870 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
4871 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
4872 "accelerationStructureCount (%d) *stride(%zu).",
4873 dataSize, accelerationStructureCount, stride);
4874 }
4875 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4876 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4877 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4878 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
4879 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4880 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4881 }
4882 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
4883 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4884 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
4885 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4886 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
4887 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4888 stride);
4889 }
4890 }
4891 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
4892 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4893 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
4894 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4895 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
4896 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4897 stride);
4898 }
4899 }
4900 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4901 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4902 skip |=
4903 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
4904 "vkWriteAccelerationStructuresPropertiesKHR: the "
4905 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
4906 "feature must be enabled ");
4907 }
4908 return skip;
4909}
4910bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
4911 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
4912 bool skip = false;
4913 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4914 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
4915 skip |= LogError(device,
4916 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
4917 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
4918 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
4919 "must be enabled to call this function.");
4920 }
4921 return skip;
4922}
4923
4924bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
4925 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4926 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4927 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4928 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4929 uint32_t width, uint32_t height, uint32_t depth) const {
4930 bool skip = false;
4931 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4932 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
4933 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
4934 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4935 }
4936 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4937 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
4938 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
4939 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4940 }
4941 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4942 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
4943 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
4944 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4945 }
4946 // hitShader
4947 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4948 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
4949 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
4950 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4951 }
4952 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4953 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
4954 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
4955 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4956 }
4957 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4958 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
4959 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
4960 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4961 }
4962
4963 // missShader
4964 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4965 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
4966 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
4967 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4968 }
4969 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4970 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
4971 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
4972 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4973 }
4974 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4975 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
4976 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
4977 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4978 }
4979
4980 // raygenShader
4981 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4982 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
4983 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
4984 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4985 }
4986 return skip;
4987}
4988
4989bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
4990 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4991 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4992 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4993 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4994 VkBuffer buffer, VkDeviceSize offset) const {
4995 bool skip = false;
4996 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4997 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
4998 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
4999 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5000 "feature must be enabled.");
5001 }
5002 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5003 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5004 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5005 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5006 }
5007 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5008 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5009 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5010 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5011 }
5012 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5013 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5014 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5015 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5016 }
5017 // hitShader
5018 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5019 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5020 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5021 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5022 }
5023 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5024 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5025 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5026 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5027 }
5028 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5029 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5030 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5031 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5032 }
5033
5034 // missShader
5035 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5036 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5037 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5038 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5039 }
5040 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5041 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5042 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5043 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5044 }
5045 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5046 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5047 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5048 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5049 }
5050
5051 // raygenShader
5052 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5053 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5054 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5055 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5056 }
5057 return skip;
5058}
5059bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5060 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5061 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5062 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5063 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5064 uint32_t width, uint32_t height, uint32_t depth) const {
5065 bool skip = false;
5066 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5067 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5068 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5069 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5070 }
5071 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5072 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5073 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5074 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5075 }
5076 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5077 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5078 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5079 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5080 }
5081
5082 // hitShader
5083 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5084 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5085 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5086 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5087 }
5088 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5089 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5090 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5091 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5092 }
5093 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5094 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5095 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5096 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5097 }
5098
5099 // missShader
5100 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5101 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5102 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5103 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5104 }
5105 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5106 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5107 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5108 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5109 }
5110 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5111 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5112 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5113 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5114 }
5115
5116 // raygenShader
5117 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5118 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5119 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
5120 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment .");
5121 }
5122 return skip;
5123}
5124
5125bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5126 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5127 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5128 bool skip = false;
5129 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5130 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5131 skip |= LogError(
5132 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5133 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5134 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5135 }
5136 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5137 if (pNext_struct) {
5138 skip |=
5139 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5140 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5141 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5142 }
5143 return false;
5144}
5145
5146bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5147 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5148 bool skip = false;
5149 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5150 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5151 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5152 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5153 }
5154 return skip;
5155}
5156
5157bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5158 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5159 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5160 bool skip = false;
5161 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5162 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5163 skip |= LogError(
5164 device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5165 "vkBuildAccelerationStructureKHR: The "
5166 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5167 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005168 return skip;
5169}