blob: 2ca00e0b995727b7ffb3a91b0dfc9eaaad56a519 [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;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600160
161 uint32_t pdev_count = 0;
162 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr);
163 std::vector<VkPhysicalDevice> physical_devices;
164 physical_devices.resize(pdev_count);
165 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data());
166
167 // Need to get instance and do a getlayerdata call...
168 for (uint32_t i = 0; i < physical_devices.size(); i++) {
169 auto phys_dev_props = new VkPhysicalDeviceProperties;
170 DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props);
171 physical_device_properties_map[physical_devices[i]] = phys_dev_props;
172 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700173}
174
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600175void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
176 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
177 delete (it->second);
178 it = physical_device_properties_map.erase(it);
179 }
180};
181
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700183 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700184 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700185 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700186 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
187 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700188
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700189 // Parmeter validation also uses extension data
190 stateless_validation->device_extensions = this->device_extensions;
191
192 VkPhysicalDeviceProperties device_properties = {};
193 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600194 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700195 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
196
197 if (device_extensions.vk_nv_shading_rate_image) {
198 // Get the needed shading rate image limits
199 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
200 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600201 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700202 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
203 }
204
205 if (device_extensions.vk_nv_mesh_shader) {
206 // Get the needed mesh shader limits
207 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
208 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600209 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700210 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
211 }
212
Jason Macnak5c954952019-07-09 15:46:12 -0700213 if (device_extensions.vk_nv_ray_tracing) {
214 // Get the needed ray tracing limits
215 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
216 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
217 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500218 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
219 }
220
221 if (device_extensions.vk_khr_ray_tracing) {
222 // Get the needed ray tracing limits
223 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
224 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
225 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
226 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700227 }
228
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700229 if (device_extensions.vk_ext_transform_feedback) {
230 // Get the needed transform feedback limits
231 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
232 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
233 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
234 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
235 }
236
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800237 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
238
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700239 // Save app-enabled features in this device's validation object
240 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200241 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
242 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
243 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
244 if (features2) {
245 tmp_features2_state.features = features2->features;
246 } else if (pCreateInfo->pEnabledFeatures) {
247 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700248 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200249 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700250 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200251 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700252 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200253 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700254}
255
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700256bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500257 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600258 bool skip = false;
259
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200260 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
261 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
262 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600263 }
264
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200265 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
266 skip |=
267 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
268 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
269 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
270 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600271 }
272
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200273 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700274 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
275 bool negative_viewport =
276 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200277 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700278 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
279 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
280 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200281 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600284 {
285 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
286 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
287 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
289 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
290 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600291 }
292 }
293
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600294 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
295 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600296 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
297 if (features2) {
298 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700299 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700300 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
301 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600302 }
303 }
304
Locke77fad1c2019-04-16 13:09:03 -0600305 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
306 if (features2) {
307 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700308 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
309 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
310 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600311 }
312 }
313
Jeff Bolz165818a2020-05-08 11:19:03 -0500314 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
315 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
316 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
317 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
318 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
319 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700320 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
321 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
322 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
323 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
324 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
325 "must also be VK_TRUE.");
326 }
Locke77fad1c2019-04-16 13:09:03 -0600327 auto vertex_attribute_divisor_features =
328 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
329 if (vertex_attribute_divisor_features) {
330 bool extension_found = false;
331 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
332 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
333 VK_MAX_EXTENSION_NAME_SIZE)) {
334 extension_found = true;
335 break;
336 }
337 }
338 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700339 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
340 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
341 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600342 }
343 }
344
Tony-LunarG28017bc2020-01-23 14:40:25 -0700345 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
346 if (vulkan_11_features) {
347 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
348 while (current) {
349 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
350 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
351 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700355 skip |= LogError(
356 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700357 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
358 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
359 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
360 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
361 break;
362 }
363 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
364 }
365 }
366
367 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
368 if (vulkan_12_features) {
369 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
370 while (current) {
371 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
372 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
373 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
374 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
375 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
376 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
377 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
378 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
379 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
380 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
381 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
382 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
383 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700384 skip |= LogError(
385 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700386 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
387 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
388 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
389 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
390 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
391 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
392 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
393 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
394 break;
395 }
396 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
397 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700398 // Check features are enabled if matching extension is passed in as well
399 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
400 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
401 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
402 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
403 skip |= LogError(
404 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
405 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
406 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
407 }
408 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
409 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
410 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
411 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
412 "is not VK_TRUE.",
413 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
414 }
415 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
416 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
417 skip |= LogError(
418 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
419 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
420 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
421 }
422 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
423 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
424 skip |= LogError(
425 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
426 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
427 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
428 }
429 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
430 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
431 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
432 skip |=
433 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
434 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
435 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
436 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
437 }
438 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700439 }
440
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600441 // Validate pCreateInfo->pQueueCreateInfos
442 if (pCreateInfo->pQueueCreateInfos) {
443 std::unordered_set<uint32_t> set;
444
445 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700446 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
447 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600448 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700449 skip |=
450 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
451 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
452 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
453 "index value.",
454 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600455 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700456 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
457 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
458 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
459 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600460 } else {
461 set.insert(requested_queue_family);
462 }
463
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700464 if (queue_create_info.pQueuePriorities != nullptr) {
465 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
466 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600467 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700468 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
469 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
470 "] (=%f) is not between 0 and 1 (inclusive).",
471 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600472 }
473 }
474 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700475
476 // Need to know if protectedMemory feature is passed in preCall to creating the device
477 VkBool32 protectedMemory = VK_FALSE;
478 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
479 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
480 if (protected_features) {
481 protectedMemory = protected_features->protectedMemory;
482 } else if (vulkan_11_features) {
483 protectedMemory = vulkan_11_features->protectedMemory;
484 }
485 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
486 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
487 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
488 "protectedMemory feature being set as well.");
489 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600490 }
491 }
492
sfricke-samsung30a57412020-05-15 21:14:54 -0700493 // feature dependencies for VK_KHR_variable_pointers
494 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
495 VkBool32 variablePointers = VK_FALSE;
496 VkBool32 variablePointersStorageBuffer = VK_FALSE;
497 if (vulkan_11_features) {
498 variablePointers = vulkan_11_features->variablePointers;
499 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
500 } else if (variable_pointers_features) {
501 variablePointers = variable_pointers_features->variablePointers;
502 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
503 }
504 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
505 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
506 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
507 }
508
sfricke-samsungfd76c342020-05-29 23:13:43 -0700509 // feature dependencies for VK_KHR_multiview
510 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
511 VkBool32 multiview = VK_FALSE;
512 VkBool32 multiviewGeometryShader = VK_FALSE;
513 VkBool32 multiviewTessellationShader = VK_FALSE;
514 if (vulkan_11_features) {
515 multiview = vulkan_11_features->multiview;
516 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
517 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
518 } else if (multiview_features) {
519 multiview = multiview_features->multiview;
520 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
521 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
522 }
523 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
524 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
525 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
526 }
527 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
528 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
529 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
530 }
531
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 return skip;
533}
534
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500535bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700536 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
538 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
539 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700542 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600543}
544
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700545bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500546 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100547 bool skip = false;
548
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700550 skip |=
551 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600552
553 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
554 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
555 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
556 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700557 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
558 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
559 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600560 }
561
562 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
563 // queueFamilyIndexCount uint32_t values
564 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700565 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
566 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
567 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
568 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600569 }
570 }
571
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700572 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
573 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
574 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
575 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
576 }
577
578 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
579 skip |=
580 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
581 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
582 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
583 }
584
585 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
586 skip |=
587 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
588 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
589 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
590 }
591
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600592 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
593 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
594 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
595 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
597 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
598 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 }
600 }
601
602 return skip;
603}
604
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700605bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500606 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600607 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600608
609 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600610 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
611 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
612 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
613 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
615 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
616 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 }
618
619 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
620 // queueFamilyIndexCount uint32_t values
621 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
623 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
624 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
625 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600626 }
627 }
628
Dave Houlton413a6782018-05-22 13:01:54 -0600629 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600631 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700632 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600633 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700634 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600635
Dave Houlton413a6782018-05-22 13:01:54 -0600636 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600638 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700639 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640
Dave Houlton130c0212018-01-29 13:39:56 -0700641 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700642 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
643 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700644 skip |= LogError(
645 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600646 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
647 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700648 }
649
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600650 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100651 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
652 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
654 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
655 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600656 }
657
658 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100659 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
660 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700661 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
662 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
663 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
664 ") are not equal.",
665 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100666 }
667
668 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700669 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
670 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
671 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
672 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100673 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 }
675
676 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700677 skip |= LogError(
678 device, "VUID-VkImageCreateInfo-imageType-00957",
679 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600680 }
681 }
682
Dave Houlton130c0212018-01-29 13:39:56 -0700683 // 3D image may have only 1 layer
684 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700685 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
686 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700687 }
688
689 // If multi-sample, validate type, usage, tiling and mip levels.
690 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
691 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600692 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700693 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
694 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700695 }
696
697 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
698 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
699 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
700 // At least one of the legal attachment bits must be set
701 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
703 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700704 }
705 // No flags other than the legal attachment bits may be set
706 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
707 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
709 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700710 }
711 }
712
Jeff Bolzef40fec2018-09-01 22:04:34 -0500713 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600714 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500715 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600716 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
717 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500718 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600719 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700720 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
721 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
722 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600723 }
724
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600725 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
727 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
728 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600729 }
730
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700731 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
733 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
734 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100735 }
736
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700737 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
738 skip |= LogError(
739 device, "VUID-VkImageCreateInfo-flags-01924",
740 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
741 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
742 }
743
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600744 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
745 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
746 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
747 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700748 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
749 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
750 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600751 }
752
753 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
754 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
755 // Linear tiling is unsupported
756 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, kVUID_PVError_InvalidUsage,
758 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
759 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600760 }
761
762 // Sparse 1D image isn't valid
763 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
765 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600766 }
767
768 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700769 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700770 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
771 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
772 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600773 }
774
775 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700776 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700777 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
778 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
779 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600780 }
781
782 // Multi-sample 2D image when device doesn't support it
783 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700784 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600785 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700786 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
787 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
788 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700789 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600790 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700791 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
792 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
793 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700794 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600795 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700796 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
797 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
798 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700799 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600800 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700801 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
802 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
803 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600804 }
805 }
806 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500807
Jeff Bolz9af91c52018-09-01 21:53:57 -0500808 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
809 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
811 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
812 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500813 }
814 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700815 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
816 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
817 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500818 }
819 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700820 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
821 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
822 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500823 }
824 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500825
826 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600827 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700828 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
829 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
830 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500831 }
832
Dave Houlton142c4cb2018-10-17 15:04:41 -0600833 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700834 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
835 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
836 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
837 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500838 }
839
Dave Houlton142c4cb2018-10-17 15:04:41 -0600840 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700841 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
842 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
843 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
844 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500845 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600846 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
848 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
849 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
850 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500851 }
852 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500853
sfricke-samsung8f658d42020-05-03 20:12:24 -0700854 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
855 (FormatHasDepth(pCreateInfo->format) == false)) {
856 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
857 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
858 "format must be a depth or depth/stencil format.");
859 }
860
Andrew Fobel3abeb992020-01-20 16:33:22 -0500861 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
862 if (image_stencil_struct != nullptr) {
863 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
864 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
865 // No flags other than the legal attachment bits may be set
866 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
867 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700868 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
869 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
870 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
871 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500872 }
873 }
874
875 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
876 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
877 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
878 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700879 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
880 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
881 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
882 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500883 }
884
885 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
886 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700887 LogError(device, "VUID-VkImageCreateInfo-format-02537",
888 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
889 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
890 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500891 }
892 }
893
894 if (!physical_device_features.shaderStorageImageMultisample &&
895 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
896 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
897 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700898 LogError(device, "VUID-VkImageCreateInfo-format-02538",
899 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
900 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
901 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500902 }
903
904 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
905 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700906 skip |= LogError(
907 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500908 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
909 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
910 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
911 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
912 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700913 skip |= LogError(
914 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500915 "vkCreateImage(): Depth-stencil image in which usage does not include "
916 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
917 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
918 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
919 }
920
921 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
922 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700923 skip |= LogError(
924 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500925 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
926 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
927 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
928 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
929 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700930 skip |= LogError(
931 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500932 "vkCreateImage(): Depth-stencil image in which usage does not include "
933 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
934 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
935 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
936 }
937 }
938 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700939
940 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
941 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
942 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
943 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
944 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
945 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700946
947 if (device_extensions.vk_ext_image_drm_format_modifier) {
948 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
949 const auto drm_format_mod_explict =
950 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
951 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
952 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
953 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
955 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
956 "either VkImageDrmFormatModifierListCreateInfoEXT or "
957 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
958 }
959 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
960 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
961 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
962 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
963 "in the pNext chain");
964 }
965 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200966
967 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
968 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
969 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
970 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
971 "imageType must be VK_IMAGE_TYPE_2D.");
972 }
973 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
974 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
975 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
976 "samples must be VK_SAMPLE_COUNT_1_BIT.");
977 }
978 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
979 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
980 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
981 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
982 }
983 }
984 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
985 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
986 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
987 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
988 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
989 }
990 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
991 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
992 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
993 "imageType must be VK_IMAGE_TYPE_2D.");
994 }
995 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
996 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
997 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
998 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
999 }
1000 if (pCreateInfo->mipLevels != 1) {
1001 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1002 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1003 pCreateInfo->mipLevels);
1004 }
1005 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001006
1007 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
1008 if (swapchain_create_info != nullptr) {
1009 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1010 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1011 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1012 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1013 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1014 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1015
1016 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1017 // also implicitly forces the check above that extent.depth is 1
1018 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1019 string_VkImageType(pCreateInfo->imageType));
1020 }
1021 if (pCreateInfo->mipLevels != 1) {
1022 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1023 pCreateInfo->mipLevels);
1024 }
1025 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1026 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1027 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1028 }
1029 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1030 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1031 base_message, string_VkImageTiling(pCreateInfo->tiling));
1032 }
1033 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1034 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1035 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1036 }
1037 const VkImageCreateFlags valid_flags =
1038 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1039 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1040 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1041 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1042 pCreateInfo->flags);
1043 }
1044 }
1045 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001046 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001047
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001048 return skip;
1049}
1050
Jeff Bolz99e3f632020-03-24 22:59:22 -05001051bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1052 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1053 bool skip = false;
1054
1055 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001056 // Validate feature set if using CUBE_ARRAY
1057 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1058 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1059 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1060 "enabling the imageCubeArray feature.");
1061 }
1062
Jeff Bolz99e3f632020-03-24 22:59:22 -05001063 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1064 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1065 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001066 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001067 pCreateInfo->subresourceRange.layerCount);
1068 }
1069 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001070 skip |= LogError(
1071 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1072 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1073 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001074 }
1075 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001076
1077 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1078 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1079 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1080 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1081 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1082 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1083 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1084 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1085 }
1086 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1087 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1088 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1089 "not an ASTC format.",
1090 string_VkFormat(pCreateInfo->format));
1091 }
1092 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001093
1094 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1095 if (ycbcr_conversion != nullptr) {
1096 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1097 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1098 skip |= LogError(
1099 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1100 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1101 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1102 "r swizzle = %s\n"
1103 "g swizzle = %s\n"
1104 "b swizzle = %s\n"
1105 "a swizzle = %s\n",
1106 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1107 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1108 }
1109 }
1110 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001111 }
1112 return skip;
1113}
1114
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001115bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001116 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001117 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001118
1119 // Note: for numerical correctness
1120 // - float comparisons should expect NaN (comparison always false).
1121 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1122
1123 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001124 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001125 if (v1_f <= 0.0f) return true;
1126
1127 float intpart;
1128 const float fract = modff(v1_f, &intpart);
1129
1130 assert(std::numeric_limits<float>::radix == 2);
1131 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1132 if (intpart >= u32_max_plus1) return false;
1133
1134 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1135 if (v1_u32 < v2_u32)
1136 return true;
1137 else if (v1_u32 == v2_u32 && fract == 0.0f)
1138 return true;
1139 else
1140 return false;
1141 };
1142
1143 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1144 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1145 return (v1_f <= v2_f);
1146 };
1147
1148 // width
1149 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001150 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001151
1152 if (!(viewport.width > 0.0f)) {
1153 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001154 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1155 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001156 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1157 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001158 skip |= LogError(object, "VUID-VkViewport-width-01771",
1159 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1160 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001161 } 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 -07001162 skip |= LogWarning(object, kVUID_PVError_NONE,
1163 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1164 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1165 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001166 }
1167
1168 // height
1169 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001170 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001171 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001172
1173 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1174 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001175 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1176 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001177 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1178 height_healthy = false;
1179
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001180 skip |= LogError(object, "VUID-VkViewport-height-01773",
1181 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1182 ").",
1183 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001184 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1185 height_healthy = false;
1186
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001187 skip |= LogWarning(
1188 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001189 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001190 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001191 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001192 }
1193
1194 // x
1195 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001196 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001197 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001198 skip |= LogError(object, "VUID-VkViewport-x-01774",
1199 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1200 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001201 }
1202
1203 // x + width
1204 if (x_healthy && width_healthy) {
1205 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001206 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001207 skip |= LogError(
1208 object, "VUID-VkViewport-x-01232",
1209 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1210 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1211 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001212 }
1213 }
1214
1215 // y
1216 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001217 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001218 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001219 skip |= LogError(object, "VUID-VkViewport-y-01775",
1220 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1221 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001222 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001223 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001224 skip |= LogError(object, "VUID-VkViewport-y-01776",
1225 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1226 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001227 }
1228
1229 // y + height
1230 if (y_healthy && height_healthy) {
1231 const float boundary = viewport.y + viewport.height;
1232
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001233 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001234 skip |= LogError(object, "VUID-VkViewport-y-01233",
1235 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1236 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1237 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001238 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001239 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001240 LogError(object, "VUID-VkViewport-y-01777",
1241 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1242 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1243 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001244 }
1245 }
1246
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001247 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001248 // minDepth
1249 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001250 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001251
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001252 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1253 "[0.0, 1.0] range.",
1254 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001255 }
1256
1257 // maxDepth
1258 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001259 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001260
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001261 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1262 "[0.0, 1.0] range.",
1263 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001264 }
1265 }
1266
1267 return skip;
1268}
1269
Dave Houlton142c4cb2018-10-17 15:04:41 -06001270struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001271 VkShadingRatePaletteEntryNV shadingRate;
1272 uint32_t width;
1273 uint32_t height;
1274};
1275
1276// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001277static SampleOrderInfo sampleOrderInfos[] = {
1278 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1279 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1280 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1281 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1282 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1283 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001284};
1285
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001286bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001287 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001288
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001289 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001290 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001291 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001292 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001293 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001294 break;
1295 }
1296 }
1297
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001298 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001299 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1300 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1301 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001302 return skip;
1303 }
1304
Dave Houlton142c4cb2018-10-17 15:04:41 -06001305 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001306 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001307 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1308 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1309 ") must "
1310 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1311 "is set in framebufferNoAttachmentsSampleCounts.",
1312 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001313 }
1314
Jeff Bolz9af91c52018-09-01 21:53:57 -05001315 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001316 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1317 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1318 ") must "
1319 "be equal to the product of sampleCount (=%" PRIu32
1320 "), the fragment width for shadingRate "
1321 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1322 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001323 }
1324
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001325 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001326 skip |= LogError(
1327 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001328 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1329 ") must "
1330 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001331 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001332 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001333
1334 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001335 // the first width*height*sampleCount bits to all be set. Note: There is no
1336 // guarantee that 64 bits is enough, but practically it's unlikely for an
1337 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001338 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001339 uint64_t sampleLocationsMask = 0;
1340 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1341 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1342 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001343 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1344 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001345 }
1346 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001347 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1348 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001349 }
1350 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001351 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1352 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001353 }
1354 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1355 sampleLocationsMask |= 1ULL << idx;
1356 }
1357
1358 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1359 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001360 skip |= LogError(
1361 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001362 "The array pSampleLocations must contain exactly one entry for "
1363 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001364 }
1365
1366 return skip;
1367}
1368
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001369bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1370 uint32_t createInfoCount,
1371 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1372 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001373 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001374 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001375
1376 if (pCreateInfos != nullptr) {
1377 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001378 bool has_dynamic_viewport = false;
1379 bool has_dynamic_scissor = false;
1380 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001381 bool has_dynamic_depth_bias = false;
1382 bool has_dynamic_blend_constant = false;
1383 bool has_dynamic_depth_bounds = false;
1384 bool has_dynamic_stencil_compare = false;
1385 bool has_dynamic_stencil_write = false;
1386 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001387 bool has_dynamic_viewport_w_scaling_nv = false;
1388 bool has_dynamic_discard_rectangle_ext = false;
1389 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001390 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001391 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001392 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001393 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001394 bool has_dynamic_cull_mode = false;
1395 bool has_dynamic_front_face = false;
1396 bool has_dynamic_primitive_topology = false;
1397 bool has_dynamic_viewport_with_count = false;
1398 bool has_dynamic_scissor_with_count = false;
1399 bool has_dynamic_vertex_input_binding_stride = false;
1400 bool has_dynamic_depth_test_enable = false;
1401 bool has_dynamic_depth_write_enable = false;
1402 bool has_dynamic_depth_compare_op = false;
1403 bool has_dynamic_depth_bounds_test_enable = false;
1404 bool has_dynamic_stencil_test_enable = false;
1405 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001406 if (pCreateInfos[i].pDynamicState != nullptr) {
1407 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1408 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1409 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001410 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1411 if (has_dynamic_viewport == true) {
1412 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1413 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1414 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1415 i);
1416 }
1417 has_dynamic_viewport = true;
1418 }
1419 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1420 if (has_dynamic_scissor == true) {
1421 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1422 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1423 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1424 i);
1425 }
1426 has_dynamic_scissor = true;
1427 }
1428 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1429 if (has_dynamic_line_width == true) {
1430 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1431 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1432 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1433 i);
1434 }
1435 has_dynamic_line_width = true;
1436 }
1437 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1438 if (has_dynamic_depth_bias == true) {
1439 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1440 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1441 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1442 i);
1443 }
1444 has_dynamic_depth_bias = true;
1445 }
1446 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1447 if (has_dynamic_blend_constant == true) {
1448 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1449 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1450 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1451 i);
1452 }
1453 has_dynamic_blend_constant = true;
1454 }
1455 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1456 if (has_dynamic_depth_bounds == true) {
1457 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1458 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1459 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1460 i);
1461 }
1462 has_dynamic_depth_bounds = true;
1463 }
1464 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1465 if (has_dynamic_stencil_compare == true) {
1466 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1467 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1468 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1469 i);
1470 }
1471 has_dynamic_stencil_compare = true;
1472 }
1473 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1474 if (has_dynamic_stencil_write == true) {
1475 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1476 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1477 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1478 i);
1479 }
1480 has_dynamic_stencil_write = true;
1481 }
1482 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1483 if (has_dynamic_stencil_reference == true) {
1484 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1485 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1486 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1487 i);
1488 }
1489 has_dynamic_stencil_reference = true;
1490 }
1491 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1492 if (has_dynamic_viewport_w_scaling_nv == true) {
1493 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1494 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1495 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1496 i);
1497 }
1498 has_dynamic_viewport_w_scaling_nv = true;
1499 }
1500 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1501 if (has_dynamic_discard_rectangle_ext == true) {
1502 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1503 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1504 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1505 i);
1506 }
1507 has_dynamic_discard_rectangle_ext = true;
1508 }
1509 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1510 if (has_dynamic_sample_locations_ext == true) {
1511 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1512 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1513 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1514 i);
1515 }
1516 has_dynamic_sample_locations_ext = true;
1517 }
1518 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1519 if (has_dynamic_exclusive_scissor_nv == true) {
1520 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1521 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1522 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1523 i);
1524 }
1525 has_dynamic_exclusive_scissor_nv = true;
1526 }
1527 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1528 if (has_dynamic_shading_rate_palette_nv == true) {
1529 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1530 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1531 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1532 i);
1533 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001534 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001535 }
1536 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1537 if (has_dynamic_viewport_course_sample_order_nv == true) {
1538 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1539 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1540 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1541 i);
1542 }
1543 has_dynamic_viewport_course_sample_order_nv = true;
1544 }
1545 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1546 if (has_dynamic_line_stipple == true) {
1547 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1548 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1549 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1550 i);
1551 }
1552 has_dynamic_line_stipple = true;
1553 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001554 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1555 if (has_dynamic_cull_mode) {
1556 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1557 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1558 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1559 i);
1560 }
1561 has_dynamic_cull_mode = true;
1562 }
1563 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1564 if (has_dynamic_front_face) {
1565 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1566 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1567 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1568 i);
1569 }
1570 has_dynamic_front_face = true;
1571 }
1572 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1573 if (has_dynamic_primitive_topology) {
1574 skip |= LogError(
1575 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1576 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1577 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1578 i);
1579 }
1580 has_dynamic_primitive_topology = true;
1581 }
1582 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1583 if (has_dynamic_viewport_with_count) {
1584 skip |= LogError(
1585 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1586 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1587 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1588 i);
1589 }
1590 has_dynamic_viewport_with_count = true;
1591 }
1592 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1593 if (has_dynamic_scissor_with_count) {
1594 skip |= LogError(
1595 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1596 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1597 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1598 i);
1599 }
1600 has_dynamic_scissor_with_count = true;
1601 }
1602 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1603 if (has_dynamic_vertex_input_binding_stride) {
1604 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1605 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1606 "listed twice in the "
1607 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1608 i);
1609 }
1610 has_dynamic_vertex_input_binding_stride = true;
1611 }
1612 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1613 if (has_dynamic_depth_test_enable) {
1614 skip |= LogError(
1615 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1616 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1617 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1618 i);
1619 }
1620 has_dynamic_depth_test_enable = true;
1621 }
1622 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1623 if (has_dynamic_depth_write_enable) {
1624 skip |= LogError(
1625 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1626 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1627 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1628 i);
1629 }
1630 has_dynamic_depth_write_enable = true;
1631 }
1632 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1633 if (has_dynamic_depth_compare_op) {
1634 skip |=
1635 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1636 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1637 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1638 i);
1639 }
1640 has_dynamic_depth_compare_op = true;
1641 }
1642 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1643 if (has_dynamic_depth_bounds_test_enable) {
1644 skip |= LogError(
1645 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1646 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1647 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1648 i);
1649 }
1650 has_dynamic_depth_bounds_test_enable = true;
1651 }
1652 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1653 if (has_dynamic_stencil_test_enable) {
1654 skip |= LogError(
1655 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1656 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1657 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1658 i);
1659 }
1660 has_dynamic_stencil_test_enable = true;
1661 }
1662 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1663 if (has_dynamic_stencil_op) {
1664 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1665 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1666 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1667 i);
1668 }
1669 has_dynamic_stencil_op = true;
1670 }
Petr Kraus299ba622017-11-24 03:09:03 +01001671 }
1672 }
1673
Peter Chen85366392019-05-14 15:20:11 -04001674 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1675 if ((feedback_struct != nullptr) &&
1676 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001677 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1678 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1679 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1680 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1681 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001682 }
1683
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001684 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001685
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001686 // Collect active stages and other information
1687 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001688 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001689 bool has_eval = false;
1690 bool has_control = false;
1691 if (pCreateInfos[i].pStages != nullptr) {
1692 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1693 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1694
1695 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1696 has_control = true;
1697 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1698 has_eval = true;
1699 }
1700
1701 skip |= validate_string(
1702 "vkCreateGraphicsPipelines",
1703 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1704 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1705 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001706 }
1707
1708 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1709 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1710 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1711 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1712 pCreateInfos[i].pTessellationState,
1713 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1714 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1715
1716 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1717 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1718
1719 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1720 "VkPipelineTessellationDomainOriginStateCreateInfo",
1721 pCreateInfos[i].pTessellationState->pNext,
1722 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1723 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001724 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1725 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001726
1727 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1728 pCreateInfos[i].pTessellationState->flags,
1729 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1730 }
1731
1732 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1733 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1734 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1735 pCreateInfos[i].pInputAssemblyState,
1736 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1737 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1738
1739 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1740 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001741 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001742
1743 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1744 pCreateInfos[i].pInputAssemblyState->flags,
1745 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1746
1747 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1748 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1749 pCreateInfos[i].pInputAssemblyState->topology,
1750 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1751
1752 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1753 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1754 }
1755
1756 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001757 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001758
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001759 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001760 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1761 "vkCreateGraphicsPipelines: pararameter "
1762 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1763 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001764 }
1765
1766 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1767 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1768 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1769 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1770 pCreateInfos[i].pVertexInputState->pNext, 1,
1771 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001772 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1773 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001774 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1775 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001776 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001777 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1778 skip |=
1779 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1780 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1781 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1782 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1783 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1784
1785 skip |= validate_array(
1786 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1787 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1788 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1789 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1790
1791 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1792 for (uint32_t vertexBindingDescriptionIndex = 0;
1793 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1794 ++vertexBindingDescriptionIndex) {
1795 skip |= validate_ranged_enum(
1796 "vkCreateGraphicsPipelines",
1797 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1798 AllVkVertexInputRateEnums,
1799 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1800 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1801 }
1802 }
1803
1804 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1805 for (uint32_t vertexAttributeDescriptionIndex = 0;
1806 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1807 ++vertexAttributeDescriptionIndex) {
1808 skip |= validate_ranged_enum(
1809 "vkCreateGraphicsPipelines",
1810 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1811 AllVkFormatEnums,
1812 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1813 "VUID-VkVertexInputAttributeDescription-format-parameter");
1814 }
1815 }
1816
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001817 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001818 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1819 "vkCreateGraphicsPipelines: pararameter "
1820 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1821 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1822 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001823 }
1824
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001825 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001826 skip |=
1827 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1828 "vkCreateGraphicsPipelines: pararameter "
1829 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1830 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1831 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001832 }
1833
1834 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1836 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001837 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1838 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001839 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1840 "vkCreateGraphicsPipelines: parameter "
1841 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1842 "(%" PRIu32 ") is not distinct.",
1843 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001844 }
1845 vertex_bindings.insert(vertex_bind_desc.binding);
1846
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001847 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001848 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1849 "vkCreateGraphicsPipelines: parameter "
1850 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1851 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1852 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001853 }
1854
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001855 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001856 skip |=
1857 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1858 "vkCreateGraphicsPipelines: parameter "
1859 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1860 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1861 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001862 }
1863 }
1864
Peter Kohautc7d9d392018-07-15 00:34:07 +02001865 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001866 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1867 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001868 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1869 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001870 skip |= LogError(
1871 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001872 "vkCreateGraphicsPipelines: parameter "
1873 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1874 i, d, vertex_attrib_desc.location);
1875 }
1876 attribute_locations.insert(vertex_attrib_desc.location);
1877
1878 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1879 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001880 skip |= LogError(
1881 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001882 "vkCreateGraphicsPipelines: parameter "
1883 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1884 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1885 i, d, vertex_attrib_desc.binding, i);
1886 }
1887
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001888 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001889 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1890 "vkCreateGraphicsPipelines: parameter "
1891 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1892 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1893 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001894 }
1895
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001896 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001897 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1898 "vkCreateGraphicsPipelines: parameter "
1899 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1900 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1901 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001902 }
1903
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001904 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001905 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1906 "vkCreateGraphicsPipelines: parameter "
1907 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1908 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1909 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001910 }
1911 }
1912 }
1913
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001914 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1915 if (has_control && has_eval) {
1916 if (pCreateInfos[i].pTessellationState == nullptr) {
1917 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1918 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1919 "shader stage and a tessellation evaluation shader stage, "
1920 "pCreateInfos[%d].pTessellationState must not be NULL.",
1921 i, i);
1922 } else {
1923 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1924 skip |= validate_struct_pnext(
1925 "vkCreateGraphicsPipelines",
1926 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1927 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1928 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1929 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001930
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001931 skip |= validate_reserved_flags(
1932 "vkCreateGraphicsPipelines",
1933 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1934 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001935
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001936 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1937 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1938 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1939 "vkCreateGraphicsPipelines: invalid parameter "
1940 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1941 "should be >0 and <=%u.",
1942 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1943 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001944 }
1945 }
1946 }
1947
1948 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1949 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1950 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1951 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001952 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1953 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1954 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1955 "].pViewportState (=NULL) is not a valid pointer.",
1956 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001957 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001958 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1959
1960 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001961 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1962 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1963 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1964 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001965 }
1966
Petr Krausa6103552017-11-16 21:21:58 +01001967 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1968 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001969 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1970 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001971 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1972 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001973 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001974 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001975 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001976 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001977 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001978 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1979 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001980 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001981 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1982 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001983
1984 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001985 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001986 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001987 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988
Dave Houlton142c4cb2018-10-17 15:04:41 -06001989 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1990 pCreateInfos[i].pViewportState->pNext);
1991 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1992 pCreateInfos[i].pViewportState->pNext);
1993 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1994 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001995 const auto vp_swizzle_struct =
1996 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001997 const auto vp_w_scaling_struct =
1998 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001999
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002000 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01002001 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002002 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
2003 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2004 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
2005 ") is not 1.",
2006 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002007 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002008
Petr Krausa6103552017-11-16 21:21:58 +01002009 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002010 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
2011 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2012 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2013 ") is not 1.",
2014 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002015 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002016
Dave Houlton142c4cb2018-10-17 15:04:41 -06002017 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2018 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002019 skip |= LogError(
2020 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2021 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2022 "disabled, but pCreateInfos[%" PRIu32
2023 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2024 ") is not 1.",
2025 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002026 }
2027
Jeff Bolz9af91c52018-09-01 21:53:57 -05002028 if (shading_rate_image_struct &&
2029 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002030 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2031 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2032 "disabled, but pCreateInfos[%" PRIu32
2033 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2034 ") is neither 0 nor 1.",
2035 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002036 }
2037
Petr Krausa6103552017-11-16 21:21:58 +01002038 } else { // multiViewport enabled
2039 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002040 if (!has_dynamic_viewport_with_count) {
2041 skip |= LogError(
2042 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2043 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2044 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002045 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002046 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2047 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2048 "].pViewportState->viewportCount (=%" PRIu32
2049 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2050 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002051 } else if (has_dynamic_viewport_with_count) {
2052 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2053 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2054 "].pViewportState->viewportCount (=%" PRIu32
2055 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2056 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002057 }
Petr Krausa6103552017-11-16 21:21:58 +01002058
2059 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002060 if (!has_dynamic_scissor_with_count) {
2061 skip |= LogError(
2062 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2063 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2064 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002065 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002066 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2067 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2068 "].pViewportState->scissorCount (=%" PRIu32
2069 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2070 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002071 } else if (has_dynamic_scissor_with_count) {
2072 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2073 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2074 "].pViewportState->scissorCount (=%" PRIu32
2075 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2076 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002077 }
2078 }
2079
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002080 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002081 skip |=
2082 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2083 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2084 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2085 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002086 }
2087
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002088 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002089 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2090 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2091 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2092 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2093 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002094 }
2095
Piers Daniell39842ee2020-07-10 16:42:33 -06002096 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2097 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002098 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2099 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2100 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2101 "].pViewportState->viewportCount (=%" PRIu32 ").",
2102 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002103 }
2104
Dave Houlton142c4cb2018-10-17 15:04:41 -06002105 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002106 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |=
2108 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2109 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2110 ") must be zero or identical to pCreateInfos[%" PRIu32
2111 "].pViewportState->viewportCount (=%" PRIu32 ").",
2112 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002113 }
2114
Dave Houlton142c4cb2018-10-17 15:04:41 -06002115 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002116 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002117 skip |= LogError(
2118 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002119 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2120 "] "
2121 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2122 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2123 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002124 }
2125
Petr Krausa6103552017-11-16 21:21:58 +01002126 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002127 skip |= LogError(
2128 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002129 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2130 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002131 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2132 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002133 }
2134
2135 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002136 skip |= LogError(
2137 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002138 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2139 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002140 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2141 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002142 }
2143
Jeff Bolz3e71f782018-08-29 23:15:45 -05002144 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002145 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2146 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2147 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002148 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002149 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2150 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2151 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2152 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002153 }
2154
Jeff Bolz9af91c52018-09-01 21:53:57 -05002155 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002156 shading_rate_image_struct->viewportCount > 0 &&
2157 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002158 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002159 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002160 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002161 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2162 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002163 i, i);
2164 }
2165
Chris Mayer328d8212018-12-11 14:16:18 +01002166 if (vp_swizzle_struct) {
2167 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002168 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2169 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2170 " does "
2171 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2172 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002173 }
2174 }
2175
Petr Krausb3fcdb42018-01-09 22:09:09 +01002176 // validate the VkViewports
2177 if (!has_dynamic_viewport && viewport_state.pViewports) {
2178 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2179 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002180 const char *fn_name = "vkCreateGraphicsPipelines";
2181 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2182 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2183 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002184 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002185 }
2186 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002187
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002188 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002189 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2190 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2191 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2192 "VK_NV_clip_space_w_scaling extension is not enabled.",
2193 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002194 }
2195
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002196 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002197 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2198 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2199 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2200 "VK_EXT_discard_rectangles extension is not enabled.",
2201 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002202 }
2203
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002204 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002205 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2206 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2207 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2208 "VK_EXT_sample_locations extension is not enabled.",
2209 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002210 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002211
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002212 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002213 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2214 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2215 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2216 "VK_NV_scissor_exclusive extension is not enabled.",
2217 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002218 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002219
2220 if (coarse_sample_order_struct &&
2221 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2222 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002223 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2224 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2225 "] "
2226 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2227 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2228 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002229 }
2230
2231 if (coarse_sample_order_struct) {
2232 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002233 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002234 }
2235 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002236
2237 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2238 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002239 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2240 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2241 "] "
2242 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2243 ") "
2244 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2245 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002246 }
2247 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002248 skip |= LogError(
2249 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002250 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2251 "] "
2252 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2253 i);
2254 }
2255 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 }
2257
2258 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002259 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2260 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2261 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2262 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002263 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002264 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
2265 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2266 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002267 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002268 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002269 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002271 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002272 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002273 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002274 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2275 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002276
2277 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002278 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002279 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002280 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281
2282 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002283 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2285 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2286
2287 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002288 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2290 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002291 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002292 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002294 skip |= validate_flags(
2295 "vkCreateGraphicsPipelines",
2296 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2297 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002298 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002299
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002301 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002302 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2303 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2304
2305 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002306 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002307 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2308 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2309
2310 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002311 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2312 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2313 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2314 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315 }
John Zulauf7acac592017-11-06 11:15:53 -07002316 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002317 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002318 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2319 "vkCreateGraphicsPipelines(): parameter "
2320 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2321 i);
John Zulauf7acac592017-11-06 11:15:53 -07002322 }
2323 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2324 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2325 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002326 skip |= LogError(
2327 device,
2328
Dave Houlton413a6782018-05-22 13:01:54 -06002329 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002330 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002331 }
2332 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002333
2334 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2335 pCreateInfos[i].pRasterizationState->pNext);
2336
2337 if (line_state) {
2338 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2339 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2340 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2341 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002342 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2343 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2344 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2345 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002346 }
2347 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2348 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002349 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2350 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2351 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2352 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002353 }
2354 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2355 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002356 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2357 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2358 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2359 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002360 }
2361 }
2362 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2363 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2364 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002365 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2366 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2367 "range [1,256].",
2368 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002369 }
2370 }
2371 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002372 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002373 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2374 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002375 skip |=
2376 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2377 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2378 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2379 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002380 }
2381 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2382 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |=
2384 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2385 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2386 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2387 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002388 }
2389 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2390 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 skip |=
2392 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2393 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2394 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2395 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002396 }
2397 if (line_state->stippledLineEnable) {
2398 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2399 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |=
2401 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2402 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2403 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2404 "stippledRectangularLines feature.",
2405 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002406 }
2407 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2408 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002409 skip |=
2410 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2411 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2412 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2413 "stippledBresenhamLines feature.",
2414 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002415 }
2416 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2417 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002418 skip |=
2419 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2420 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2421 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2422 "stippledSmoothLines feature.",
2423 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002424 }
2425 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2426 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002427 skip |=
2428 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2429 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2430 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2431 "stippledRectangularLines and strictLines features.",
2432 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002433 }
2434 }
2435 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
2437
Petr Krause91f7a12017-12-14 20:57:36 +01002438 bool uses_color_attachment = false;
2439 bool uses_depthstencil_attachment = false;
2440 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002441 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002442 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2443 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002444 const auto &subpasses_uses = subpasses_uses_it->second;
2445 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2446 uses_color_attachment = true;
2447 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2448 uses_depthstencil_attachment = true;
2449 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002450 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002451 }
2452
2453 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002455 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002456 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002457 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002458 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459
2460 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002461 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002462 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002463 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464
2465 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002466 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002467 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2468 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2469
2470 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002471 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002472 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2473 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2474
2475 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2478 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002479 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002480
2481 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002482 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002483 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2484 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2485
2486 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002487 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2489 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2490
2491 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002492 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002493 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2494 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002495 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002496
2497 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002498 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002499 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2500 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002501 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002502
2503 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002504 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2506 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002507 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508
2509 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002510 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002511 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2512 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002513 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002514
2515 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002516 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002517 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2518 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002519 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002520
2521 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002522 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002523 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2524 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002525 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526
2527 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002528 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002529 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2530 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002531 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002532
2533 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002534 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002535 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2536 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002537 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002538
2539 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002540 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2541 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2542 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2543 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002544 }
2545 }
2546
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002547 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2548 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2549
Petr Krause91f7a12017-12-14 20:57:36 +01002550 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002551 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2552 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2553 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2554 pCreateInfos[i].pColorBlendState,
2555 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2556 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2557
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002559 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002560 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2561 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2562 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002563 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002564 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2565 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566
2567 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002568 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002569 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002570 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002571
2572 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002573 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002574 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2575 pCreateInfos[i].pColorBlendState->logicOpEnable);
2576
2577 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002578 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002579 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2580 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002581 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002582 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583
2584 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2585 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2586 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002587 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002588 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2589 ParameterName::IndexVector{i, attachmentIndex}),
2590 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2591
2592 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002593 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002594 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2595 ParameterName::IndexVector{i, attachmentIndex}),
2596 "VkBlendFactor", AllVkBlendFactorEnums,
2597 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002598 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599
2600 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002601 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002602 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2603 ParameterName::IndexVector{i, attachmentIndex}),
2604 "VkBlendFactor", AllVkBlendFactorEnums,
2605 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002606 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607
2608 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002609 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2611 ParameterName::IndexVector{i, attachmentIndex}),
2612 "VkBlendOp", AllVkBlendOpEnums,
2613 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002614 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615
2616 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002617 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002618 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2619 ParameterName::IndexVector{i, attachmentIndex}),
2620 "VkBlendFactor", AllVkBlendFactorEnums,
2621 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002622 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623
2624 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002625 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002626 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2627 ParameterName::IndexVector{i, attachmentIndex}),
2628 "VkBlendFactor", AllVkBlendFactorEnums,
2629 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002630 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631
2632 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002633 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002634 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2635 ParameterName::IndexVector{i, attachmentIndex}),
2636 "VkBlendOp", AllVkBlendOpEnums,
2637 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002638 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002639
2640 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002641 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002642 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2643 ParameterName::IndexVector{i, attachmentIndex}),
2644 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2645 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002646 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 }
2648 }
2649
2650 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002651 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2652 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2653 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2654 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002655 }
2656
2657 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2658 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2659 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002660 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002661 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002662 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2663 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002664 }
2665 }
2666 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002667
Petr Kraus9752aae2017-11-24 03:05:50 +01002668 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2669 if (pCreateInfos[i].basePipelineIndex != -1) {
2670 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002671 skip |=
2672 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002673 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002674 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002675 "and pCreateInfos->basePipelineIndex is not -1.",
2676 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 }
2678 }
2679
Petr Kraus9752aae2017-11-24 03:05:50 +01002680 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2681 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002682 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002683 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002684 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002685 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2686 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002688 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002689 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002690 skip |=
2691 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2692 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2693 "index into the pCreateInfos array, of size %d.",
2694 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002695 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002696 }
2697 }
2698
sfricke-samsung898cf222020-05-15 23:10:19 -07002699 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2700 skip |= LogError(
2701 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2702 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2703 i);
2704 }
2705
Petr Kraus9752aae2017-11-24 03:05:50 +01002706 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002707 if (!device_extensions.vk_nv_fill_rectangle) {
2708 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2709 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2711 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2712 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2713 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002714 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2715 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2717 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002718 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2719 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2720 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002721 }
2722 } else {
2723 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2724 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2725 (physical_device_features.fillModeNonSolid == false)) {
2726 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002727 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2728 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002729 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2730 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2731 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002732 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733 }
Petr Kraus299ba622017-11-24 03:09:03 +01002734
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002735 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002736 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2738 "The line width state is static (pCreateInfos[%" PRIu32
2739 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2740 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2741 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2742 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002743 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002744 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745 }
2746 }
2747
2748 return skip;
2749}
2750
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002751bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2752 uint32_t createInfoCount,
2753 const VkComputePipelineCreateInfo *pCreateInfos,
2754 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002755 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002756 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002758 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002760 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002761 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2762 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002763 skip |=
2764 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2765 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2766 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2767 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002768 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002769
2770 // Make sure compute stage is selected
2771 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002772 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2773 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2774 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002775 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002776 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002777 return skip;
2778}
2779
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002780bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002781 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002783
2784 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002785 const auto &features = physical_device_features;
2786 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002787
John Zulauf71968502017-10-26 13:51:15 -06002788 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2789 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002790 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2791 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2792 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2793 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002794 }
2795
2796 // Anistropy cannot be enabled in sampler unless enabled as a feature
2797 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002798 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2799 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2800 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002801 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002802 }
John Zulauf71968502017-10-26 13:51:15 -06002803
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002804 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2805 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002806 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2807 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2808 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2809 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002810 }
2811 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002812 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2813 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2814 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2815 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002816 }
2817 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002818 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2819 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2820 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2821 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002822 }
2823 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2824 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2825 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2826 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002827 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2828 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2829 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2830 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2831 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2832 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002833 }
2834 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002835 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2836 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2837 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002838 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002839 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002840 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2841 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2842 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002843 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002844 }
2845
2846 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2847 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002848 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2849 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002850 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2851 if (sampler_reduction != nullptr) {
2852 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2853 skip |= LogError(
2854 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2855 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2856 }
2857 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002858 }
2859
2860 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2861 // valid VkBorderColor value
2862 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2863 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2864 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002865 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2866 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 }
2868
2869 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2870 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002871 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002872 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2873 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2874 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002875 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002876 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2877 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2878 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 }
John Zulauf275805c2017-10-26 15:34:49 -06002880
2881 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002882 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002883 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2884 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002885 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2886 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2887 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002888 }
2889 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002890
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002891 // Check for valid Lod range
2892 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002893 skip |=
2894 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2895 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002896 }
2897
2898 // Check mipLodBias to device limit
2899 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002900 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2901 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2902 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002903 }
2904
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002905 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2906 if (sampler_conversion != nullptr) {
2907 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2908 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2909 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2910 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002911 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002912 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002913 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2914 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2915 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2916 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2917 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2918 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2919 }
2920 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002921
2922 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2923 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2924 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2925 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2926 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2927 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2928 }
2929 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2930 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2931 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2932 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2933 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2934 }
2935 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2936 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2937 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2938 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2939 pCreateInfo->minLod, pCreateInfo->maxLod);
2940 }
2941 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2942 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2943 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2944 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2945 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2946 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2947 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2948 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2949 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2950 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2951 }
2952 if (pCreateInfo->anisotropyEnable) {
2953 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2954 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2955 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2956 }
2957 if (pCreateInfo->compareEnable) {
2958 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2959 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2960 "pCreateInfo->compareEnable must be VK_FALSE");
2961 }
2962 if (pCreateInfo->unnormalizedCoordinates) {
2963 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2964 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2965 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2966 }
2967 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002968 }
2969
Tony-LunarG7337b312020-04-15 16:40:25 -06002970 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2971 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2972 if (!device_extensions.vk_ext_custom_border_color) {
2973 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2974 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2975 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2976 }
2977 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2978 if (!custom_create_info) {
2979 skip |=
2980 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2981 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2982 "struct in pNext chain.\n",
2983 string_VkBorderColor(pCreateInfo->borderColor));
2984 } else {
2985 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2986 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2987 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2988 !FormatIsSampledFloat(custom_create_info->format)))) {
2989 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2990 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2991 "whose type does not match\n",
2992 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2993 ;
2994 }
2995 }
2996 }
2997
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 return skip;
2999}
3000
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003001bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
3002 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
3003 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003004 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003005 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003006
3007 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3008 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
3009 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
3010 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3012 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3013 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3014 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3015 ++descriptor_index) {
3016 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003017 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003018 "vkCreateDescriptorSetLayout: required parameter "
3019 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3020 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003021 }
3022 }
3023 }
3024
3025 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3026 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3027 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003028 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3029 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3030 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3031 "values.",
3032 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003033 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003034
3035 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3036 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3037 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3038 skip |=
3039 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3040 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3041 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3042 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3043 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3044 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003045 }
3046 }
3047 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048 return skip;
3049}
3050
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003051bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3052 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003053 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003054 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3055 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3056 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003057 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3058 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059}
3060
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003061bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3062 const VkWriteDescriptorSet *pDescriptorWrites,
3063 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003065
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003066 if (pDescriptorWrites != NULL) {
3067 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3068 // descriptorCount must be greater than 0
3069 if (pDescriptorWrites[i].descriptorCount == 0) {
3070 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003071 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3072 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003073 }
3074
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003075 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3076 if (validateDstSet) {
3077 // dstSet must be a valid VkDescriptorSet handle
3078 skip |= validate_required_handle(vkCallingFunction,
3079 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3080 pDescriptorWrites[i].dstSet);
3081 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082
3083 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3084 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3085 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3086 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3087 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3088 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3089 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003090 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3091 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003093 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3094 "%s(): if pDescriptorWrites[%d].descriptorType is "
3095 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3096 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3097 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3098 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3100 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003101 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3102 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003103 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3104 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003105 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003106 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3107 ParameterName::IndexVector{i, descriptor_index}),
3108 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003109 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 }
3111 }
3112 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3113 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3114 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3115 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3116 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3117 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3118 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003119 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003120 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003121 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3122 "%s(): if pDescriptorWrites[%d].descriptorType is "
3123 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3124 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3125 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3126 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003128 const auto *robustness2_features =
3129 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3130 if (robustness2_features && robustness2_features->nullDescriptor) {
3131 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
3132 ++descriptorIndex) {
3133 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
3134 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
3135 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
3136 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3137 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
3138 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
3139 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
3140 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
3141 }
3142 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 }
3144 }
3145 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3146 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003147 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
3149
3150 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3151 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003152 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003153 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3154 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3155 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003156 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003157 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3158 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3159 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3160 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 }
3162 }
3163 }
3164 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3165 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003166 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003167 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3168 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3169 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003170 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003171 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3172 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3173 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3174 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003175 }
3176 }
3177 }
3178 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003179 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3180 // or VkWriteDescriptorSetInlineUniformBlockEX
3181 if (pDescriptorWrites[i].pNext) {
3182 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003183 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003184 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003185 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003186 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3187 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3188 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3189 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003190 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003191 pDescriptorWrites[i].descriptorCount);
3192 }
3193 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003194 if (pnext_struct) {
3195 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003196 skip |= LogError(
3197 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3198 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3199 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003200 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003201 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003202 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003203 skip |= LogError(
3204 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3205 "%s(): accelerationStructureCount must be greater than 0 .");
3206 }
3207 }
3208 }
3209 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 }
3211 }
3212 return skip;
3213}
3214
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003215bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3216 const VkWriteDescriptorSet *pDescriptorWrites,
3217 uint32_t descriptorCopyCount,
3218 const VkCopyDescriptorSet *pDescriptorCopies) const {
3219 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3220}
3221
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003222bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003223 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003224 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003225 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3226}
3227
3228bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003229 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003230 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003231 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3232}
3233
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003234bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3235 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003236 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003237 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003238
3239 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3240 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3241 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003242 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3243 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244 return skip;
3245}
3246
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003247bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003248 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003249 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003250
3251 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3252 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003253 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3254
Petr Krause7bb9e82019-08-11 21:34:43 +02003255 // Implicit VUs
3256 // validate only sType here; pointer has to be validated in core_validation
3257 const bool kNotRequired = false;
3258 const char *kNoVUID = nullptr;
3259 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3260 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3261 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003262
Petr Krause7bb9e82019-08-11 21:34:43 +02003263 if (pInfo) {
3264 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3265 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3266 skip |= validate_struct_pnext(
3267 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3268 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003269 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3270 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003271
Petr Krause7bb9e82019-08-11 21:34:43 +02003272 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273
Petr Krause7bb9e82019-08-11 21:34:43 +02003274 // Explicit VUs
3275 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003276 skip |= LogError(
3277 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003278 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3279 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003280 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003281
3282 if (physical_device_features.inheritedQueries) {
3283 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003284 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003285 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003286 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003287 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003288 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003289 }
3290
3291 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003292 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003293 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003294 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003295 } else { // !pipelineStatisticsQuery
3296 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3297 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003298 }
Petr Kraus139757b2019-08-15 17:19:33 +02003299
3300 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3301 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003302 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003303 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3304 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(
3306 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003307 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3308 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3309 }
3310 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003311 }
3312
3313 return skip;
3314}
3315
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003316bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003317 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003318 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003320 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003321 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3323 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3324 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003325 }
3326 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003327 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3328 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3329 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003330 }
3331 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003332 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003333 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003334 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3335 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3336 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3337 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 }
3339 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003340
3341 if (pViewports) {
3342 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3343 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003344 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003345 skip |= manual_PreCallValidateViewport(
3346 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003347 }
3348 }
3349
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 return skip;
3351}
3352
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003353bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003354 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003355 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003356
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003357 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003359 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3360 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3361 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003362 }
3363 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003364 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3365 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3366 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003367 }
3368 } else { // multiViewport enabled
3369 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003370 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003371 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3372 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3373 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3374 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003375 }
3376 }
3377
Petr Kraus6260f0a2018-02-27 21:15:55 +01003378 if (pScissors) {
3379 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3380 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003381
Petr Kraus6260f0a2018-02-27 21:15:55 +01003382 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003383 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3384 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3385 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003386 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003387
Petr Kraus6260f0a2018-02-27 21:15:55 +01003388 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003389 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3390 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3391 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003392 }
3393
3394 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3395 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3397 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3398 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3399 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003400 }
3401
3402 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3403 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003404 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3405 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3406 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3407 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003408 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 }
3410 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003411
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412 return skip;
3413}
3414
Jeff Bolz5c801d12019-10-09 10:38:45 -05003415bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003416 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003417
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003418 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003419 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3420 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003421 }
3422
3423 return skip;
3424}
3425
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003426bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003427 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429 if (vertexCount == 0) {
3430 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3431 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003432 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 }
3434
3435 if (instanceCount == 0) {
3436 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3437 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003438 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439 }
3440 return skip;
3441}
3442
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003443bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003444 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003445 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003446
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003447 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003448 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3449 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003450 }
3451 return skip;
3452}
3453
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003454bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003455 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003457 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003458 skip |=
3459 LogError(device, kVUID_PVError_DeviceFeature,
3460 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461 }
3462 return skip;
3463}
3464
sfricke-samsungf692b972020-05-02 08:00:45 -07003465bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3466 VkDeviceSize countBufferOffset, bool khr) const {
3467 bool skip = false;
3468 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3469 if (offset & 3) {
3470 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3471 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3472 }
3473
3474 if (countBufferOffset & 3) {
3475 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3476 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3477 countBufferOffset);
3478 }
3479 return skip;
3480}
3481
3482bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3483 VkDeviceSize offset, VkBuffer countBuffer,
3484 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3485 uint32_t stride) const {
3486 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3487}
3488
3489bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3490 VkDeviceSize offset, VkBuffer countBuffer,
3491 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3492 uint32_t stride) const {
3493 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3494}
3495
3496bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3497 VkDeviceSize countBufferOffset, bool khr) const {
3498 bool skip = false;
3499 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3500 if (offset & 3) {
3501 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3502 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3503 }
3504
3505 if (countBufferOffset & 3) {
3506 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3507 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3508 countBufferOffset);
3509 }
3510 return skip;
3511}
3512
3513bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3514 VkDeviceSize offset, VkBuffer countBuffer,
3515 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3516 uint32_t stride) const {
3517 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3518}
3519
3520bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3521 VkDeviceSize offset, VkBuffer countBuffer,
3522 VkDeviceSize countBufferOffset,
3523 uint32_t maxDrawCount, uint32_t stride) const {
3524 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3525}
3526
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003527bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3528 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003529 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003530 bool skip = false;
3531 for (uint32_t rect = 0; rect < rectCount; rect++) {
3532 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003533 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3534 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003535 }
sfricke-samsung10867682020-04-25 02:20:39 -07003536 if (pRects[rect].rect.extent.width == 0) {
3537 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3538 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3539 }
3540 if (pRects[rect].rect.extent.height == 0) {
3541 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3542 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3543 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003544 }
3545 return skip;
3546}
3547
Andrew Fobel3abeb992020-01-20 16:33:22 -05003548bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3549 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3550 VkImageFormatProperties2 *pImageFormatProperties,
3551 const char *apiName) const {
3552 bool skip = false;
3553
3554 if (pImageFormatInfo != nullptr) {
3555 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3556 if (image_stencil_struct != nullptr) {
3557 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3558 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3559 // No flags other than the legal attachment bits may be set
3560 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3561 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003562 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3563 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3564 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3565 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3566 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003567 }
3568 }
3569 }
3570 }
3571
3572 return skip;
3573}
3574
3575bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3576 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3577 VkImageFormatProperties2 *pImageFormatProperties) const {
3578 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3579 "vkGetPhysicalDeviceImageFormatProperties2");
3580}
3581
3582bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3583 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3584 VkImageFormatProperties2 *pImageFormatProperties) const {
3585 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3586 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3587}
3588
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003589bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3590 VkImageLayout srcImageLayout, VkImage dstImage,
3591 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003592 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003593 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594
Dave Houltonf5217612018-02-02 16:18:52 -07003595 VkImageAspectFlags legal_aspect_flags =
3596 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 -07003597 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003598 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3599 }
3600
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003602 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003603 skip |= LogError(
3604 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003605 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606 }
Dave Houltonf5217612018-02-02 16:18:52 -07003607 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003608 skip |= LogError(
3609 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003610 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 }
3612 }
3613 return skip;
3614}
3615
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003616bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3617 VkImageLayout srcImageLayout, VkImage dstImage,
3618 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003619 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003621
Dave Houltonf5217612018-02-02 16:18:52 -07003622 VkImageAspectFlags legal_aspect_flags =
3623 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 -07003624 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003625 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3626 }
3627
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003628 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003629 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003630 skip |= LogError(
3631 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003632 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3633 }
Dave Houltonf5217612018-02-02 16:18:52 -07003634 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003635 skip |= LogError(
3636 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003637 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3638 }
3639 }
3640 return skip;
3641}
3642
sfricke-samsung3999ef62020-02-09 17:05:59 -08003643bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3644 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3645 bool skip = false;
3646
3647 if (pRegions != nullptr) {
3648 for (uint32_t i = 0; i < regionCount; i++) {
3649 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3651 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003652 }
3653 }
3654 }
3655 return skip;
3656}
3657
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003658bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3659 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003660 uint32_t regionCount,
3661 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003662 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003663
Dave Houltonf5217612018-02-02 16:18:52 -07003664 VkImageAspectFlags legal_aspect_flags =
3665 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 -07003666 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003667 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3668 }
3669
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003670 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003671 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3673 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3674 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003675 }
3676 }
3677 return skip;
3678}
3679
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003680bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3681 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003682 uint32_t regionCount,
3683 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003684 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003685
Dave Houltonf5217612018-02-02 16:18:52 -07003686 VkImageAspectFlags legal_aspect_flags =
3687 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 -07003688 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003689 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3690 }
3691
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003692 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003693 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003694 skip |= LogError(
3695 device, kVUID_PVError_UnrecognizedValue,
3696 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3697 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003698 }
3699 }
3700 return skip;
3701}
3702
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003703bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003704 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3705 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003706 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003707
3708 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003709 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3710 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3711 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003712 }
3713
3714 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003715 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3716 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3717 "), must be greater than zero and less than or equal to 65536.",
3718 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003719 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003720 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3721 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3722 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003723 }
3724 return skip;
3725}
3726
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003727bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003728 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003729 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003730
3731 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003732 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3733 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3734 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003735 }
3736
3737 if (size != VK_WHOLE_SIZE) {
3738 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003739 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003740 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3741 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003742 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003743 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3744 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003745 }
3746 }
3747 return skip;
3748}
3749
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003750bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003751 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003752 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003753 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003754
3755 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003756 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3757 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3758 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3759 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003760 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3761 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3762 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003763 }
3764
3765 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3766 // queueFamilyIndexCount uint32_t values
3767 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003768 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3769 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3770 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3771 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003772 }
3773 }
3774
Dave Houlton413a6782018-05-22 13:01:54 -06003775 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003777 }
3778
3779 return skip;
3780}
3781
Jeff Bolz5c801d12019-10-09 10:38:45 -05003782bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003783 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003784
3785 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003786 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3787 if (present_regions) {
3788 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003789 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003790 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3791 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003792 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3793 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3794 "extension swapchainCount is %i. These values must be equal.",
3795 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003796 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003797 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003798 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3799 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003800 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3801 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3802 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003803 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003804 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003805 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003806 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003808 }
3809 }
3810
3811 return skip;
3812}
3813
3814#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003815bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3816 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3817 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003818 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003819 bool skip = false;
3820
3821 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3823 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003824 }
3825
3826 return skip;
3827}
3828#endif // VK_USE_PLATFORM_WIN32_KHR
3829
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003830bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003831 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003832 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003833 bool skip = false;
3834
3835 if (pCreateInfo) {
3836 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003837 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3838 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003839 }
3840
3841 if (pCreateInfo->pPoolSizes) {
3842 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3843 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003844 skip |= LogError(
3845 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003846 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003847 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003848 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3849 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003850 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3851 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3852 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3853 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3854 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003855 }
Petr Krausc8655be2017-09-27 18:56:51 +02003856 }
3857 }
3858 }
3859
3860 return skip;
3861}
3862
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003863bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003864 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003865 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003866
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003867 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003868 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003869 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3870 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3871 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003872 }
3873
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003874 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003875 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003876 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3877 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3878 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003879 }
3880
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003881 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003882 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003883 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3884 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3885 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003886 }
3887
3888 return skip;
3889}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003890
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003891bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003892 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003893 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003894
3895 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003896 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3897 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003898 }
3899 return skip;
3900}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003901
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003902bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3903 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003904 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003905 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003906
3907 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003908 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003909 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003910 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3911 "vkCmdDispatch(): baseGroupX (%" PRIu32
3912 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3913 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003914 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3916 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3917 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3918 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003919 }
3920
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003921 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003922 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003923 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3924 "vkCmdDispatch(): baseGroupY (%" PRIu32
3925 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3926 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003927 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003928 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3929 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3930 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3931 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003932 }
3933
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003934 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003935 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003936 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3937 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3938 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3939 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003940 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003941 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3942 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3943 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3944 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003945 }
3946
3947 return skip;
3948}
3949
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003950bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3951 VkPipelineBindPoint pipelineBindPoint,
3952 VkPipelineLayout layout, uint32_t set,
3953 uint32_t descriptorWriteCount,
3954 const VkWriteDescriptorSet *pDescriptorWrites) const {
3955 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3956}
3957
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003958bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3959 uint32_t firstExclusiveScissor,
3960 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003961 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003962 bool skip = false;
3963
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003964 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003965 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003966 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003967 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3968 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3969 ") is not 0.",
3970 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003971 }
3972 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003973 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003974 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3975 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3976 ") is not 1.",
3977 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003978 }
3979 } else { // multiViewport enabled
3980 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003981 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003982 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3983 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3984 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3985 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003986 }
3987 }
3988
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003989 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003990 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3991 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3992 ") must be less than maxViewports (=%" PRIu32 ").",
3993 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003994 }
3995
3996 if (pExclusiveScissors) {
3997 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3998 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3999
4000 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004001 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4002 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
4003 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004004 }
4005
4006 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004007 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
4008 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
4009 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004010 }
4011
4012 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
4013 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004014 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
4015 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4016 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4017 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004018 }
4019
4020 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4021 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004022 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4023 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4024 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4025 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004026 }
4027 }
4028 }
4029
4030 return skip;
4031}
4032
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004033bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4034 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004035 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004036 bool skip = false;
4037 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004038 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
4039 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
4040 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004041 } else {
4042 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4043 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004044 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4045 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4046 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4047 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004048 }
4049 }
4050
4051 return skip;
4052}
4053
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004054bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4055 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004056 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004057 bool skip = false;
4058
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004059 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004060 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004061 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004062 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4063 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4064 ") is not 0.",
4065 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004066 }
4067 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004068 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004069 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4070 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4071 ") is not 1.",
4072 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004073 }
4074 }
4075
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004076 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004077 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
4078 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
4079 ") must be less than maxViewports (=%" PRIu32 ").",
4080 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004081 }
4082
4083 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004084 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004085 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4086 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4087 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4088 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004089 }
4090
4091 return skip;
4092}
4093
Jeff Bolz5c801d12019-10-09 10:38:45 -05004094bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4095 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4096 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004097 bool skip = false;
4098
Dave Houlton142c4cb2018-10-17 15:04:41 -06004099 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004100 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4101 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4102 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004103 }
4104
4105 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004106 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004107 }
4108
4109 return skip;
4110}
4111
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004112bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004113 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004114 bool skip = false;
4115
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004116 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004117 skip |= LogError(
4118 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004119 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4120 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004121 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004122 }
4123
4124 return skip;
4125}
4126
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004127bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4128 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004129 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004130 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004131 static const int condition_multiples = 0b0011;
4132 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004133 skip |= LogError(
4134 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004135 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004136 }
Lockee1c22882019-06-10 16:02:54 -06004137 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004138 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4139 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4140 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4141 stride);
Lockee1c22882019-06-10 16:02:54 -06004142 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004143 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004144 skip |= LogError(
4145 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4146 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004147 }
4148
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004149 return skip;
4150}
4151
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004152bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4153 VkDeviceSize offset, VkBuffer countBuffer,
4154 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004155 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004156 bool skip = false;
4157
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004158 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004159 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4160 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4161 "), is not a multiple of 4.",
4162 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004163 }
4164
4165 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004166 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4167 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4168 "), is not a multiple of 4.",
4169 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004170 }
4171
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004172 return skip;
4173}
4174
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004175bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004176 const VkAllocationCallbacks *pAllocator,
4177 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004178 bool skip = false;
4179
4180 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4181 if (pCreateInfo != nullptr) {
4182 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4183 // VkQueryPipelineStatisticFlagBits values
4184 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4185 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004186 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4187 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4188 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4189 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004190 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004191 if (pCreateInfo->queryCount == 0) {
4192 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4193 "vkCreateQueryPool(): queryCount must be greater than zero.");
4194 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004195 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004196 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004197}
4198
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004199bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4200 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004201 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004202 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4203 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004204}
4205
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004206void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004207 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4208 VkResult result) {
4209 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004210 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004211}
4212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004213void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004214 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4215 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004216 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004217 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004218 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004219}
4220
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004221void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4222 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004223 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004224 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004225 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004226}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004227
4228bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004229 const VkAllocationCallbacks *pAllocator,
4230 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004231 bool skip = false;
4232
4233 if (pAllocateInfo) {
4234 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4235 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004236 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4237 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004238 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004239
4240 VkMemoryAllocateFlags flags = 0;
4241 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4242 if (flags_info) {
4243 flags = flags_info->flags;
4244 }
4245
4246 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4247 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4248 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004249 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4250 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4251 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004252 }
4253
4254#ifdef VK_USE_PLATFORM_WIN32_KHR
4255 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4256#endif
4257 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4258 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4259#ifdef VK_USE_PLATFORM_ANDROID_KHR
4260 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4261#endif
4262
4263 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004264 skip |= LogError(
4265 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004266 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4267 }
4268 if (
4269#ifdef VK_USE_PLATFORM_WIN32_KHR
4270 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4271#endif
4272 (import_memory_fd && import_memory_fd->handleType) ||
4273#ifdef VK_USE_PLATFORM_ANDROID_KHR
4274 (import_memory_ahb && import_memory_ahb->buffer) ||
4275#endif
4276 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4278 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004279 }
4280 }
4281
4282 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004283 VkBool32 capture_replay = false;
4284 VkBool32 buffer_device_address = false;
4285 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4286 if (vulkan_12_features) {
4287 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4288 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4289 } else {
4290 const auto *bda_features =
4291 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4292 if (bda_features) {
4293 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4294 buffer_device_address = bda_features->bufferDeviceAddress;
4295 }
4296 }
4297 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004298 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4299 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4300 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004301 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004302 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004303 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4304 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004305 }
4306 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004307 }
4308 return skip;
4309}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004310
Jason Macnak192fa0e2019-07-26 15:07:16 -07004311bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004312 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004313 bool skip = false;
4314
4315 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4316 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4317 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004318 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004319 } else {
4320 uint32_t vertex_component_size = 0;
4321 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4322 vertex_component_size = 4;
4323 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4324 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4325 vertex_component_size = 2;
4326 }
4327 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004328 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004329 }
4330 }
4331
4332 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4333 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004334 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004335 } else {
4336 uint32_t index_element_size = 0;
4337 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4338 index_element_size = 4;
4339 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4340 index_element_size = 2;
4341 }
4342 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004343 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004344 }
4345 }
4346 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4347 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004349 }
4350 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004351 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004352 }
4353 }
4354
4355 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004356 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004357 }
4358
4359 return skip;
4360}
4361
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004362bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4363 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004364 bool skip = false;
4365
4366 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004367 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004368 }
4369 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004370 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004371 }
4372
4373 return skip;
4374}
4375
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004376bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4377 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004378 bool skip = false;
4379 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004380 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004381 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004383 }
4384 return skip;
4385}
4386
4387bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004388 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004389 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004390 bool skip = false;
4391 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004392 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4393 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4394 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004395 }
4396 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004397 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4398 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4399 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004400 }
4401 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4402 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004403 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4404 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4405 "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 -07004406 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004407 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004408 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004409 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4410 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004411 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4412 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004413 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004414 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004415 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4416 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4417 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004418 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004419 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004420 uint64_t total_triangle_count = 0;
4421 for (uint32_t i = 0; i < info.geometryCount; i++) {
4422 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004423
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004424 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004425
Jason Macnak5c954952019-07-09 15:46:12 -07004426 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4427 continue;
4428 }
4429 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4430 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004431 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004432 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4433 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4434 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004435 }
4436 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004437 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4438 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4439 for (uint32_t i = 1; i < info.geometryCount; i++) {
4440 const VkGeometryNV &geometry = info.pGeometries[i];
4441 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004442 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004443 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4444 "info.pGeometries[0].geometryType.",
4445 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004446 }
4447 }
4448 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004449 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4450 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4451 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4452 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4453 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4454 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4455 }
4456 }
4457 skip |=
4458 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004459 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004460 return skip;
4461}
4462
Ricardo Garciaa4935972019-02-21 17:43:18 +01004463bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4464 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004465 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004466 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004467 if (pCreateInfo) {
4468 if ((pCreateInfo->compactedSize != 0) &&
4469 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004470 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4471 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4472 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4473 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004474 }
Jason Macnak5c954952019-07-09 15:46:12 -07004475
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004476 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004477 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004478 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004479 return skip;
4480}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004481
Jeff Bolz5c801d12019-10-09 10:38:45 -05004482bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4483 const VkAccelerationStructureInfoNV *pInfo,
4484 VkBuffer instanceData, VkDeviceSize instanceOffset,
4485 VkBool32 update, VkAccelerationStructureNV dst,
4486 VkAccelerationStructureNV src, VkBuffer scratch,
4487 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004488 bool skip = false;
4489
4490 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004491 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004492 }
4493
4494 return skip;
4495}
4496
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004497bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4498 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4499 VkAccelerationStructureKHR *pAccelerationStructure) const {
4500 bool skip = false;
4501
4502 if (pCreateInfo) {
4503 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4504 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4505 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4506 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4507 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4508 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4509 i);
4510 }
4511 }
4512
4513 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4514 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4515 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4516 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4517 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4518 i);
4519 }
4520 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004521 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4522 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4523 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4524 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4525 skip |= LogError(
4526 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4527 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4528 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4529 }
4530 }
4531 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4532 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4533 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4534 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4535 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4536 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4537 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4538 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4539 }
4540 }
4541 }
4542
4543 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4544 pCreateInfo->maxGeometryCount != 1) {
4545 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4546 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4547 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004548 }
sourav parmard1521802020-06-07 21:49:02 -07004549 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4550 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4551 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4552 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4553 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004554
4555 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4556 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4557 skip |= LogError(
4558 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4559 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4560 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4561 }
4562
4563 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4564 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4565 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4566 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4567 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4568 }
4569
4570 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4571 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4572 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4573 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4574 if (geometry_type != first_geometry_type) {
4575 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4576 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4577 "pGeometryInfos[0].geometryType.",
4578 i);
4579 }
4580 }
4581 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004582 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4583 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4584 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4585 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4586 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4587 "maxGeometryCount %d.",
4588 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4589 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004590 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004591 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4592 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4593 if (pCreateInfo->deviceAddress != 0) {
4594 skip |=
4595 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4596 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4597 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4598 }
4599 }
sourav parmar83c31b12020-05-06 12:30:54 -07004600 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4601 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4602 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4603 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004604 return skip;
4605}
4606
Jason Macnak5c954952019-07-09 15:46:12 -07004607bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4608 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004609 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004610 bool skip = false;
4611 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004612 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4613 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004614 }
4615 return skip;
4616}
4617
Peter Chen85366392019-05-14 15:20:11 -04004618bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4619 uint32_t createInfoCount,
4620 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4621 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004622 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004623 bool skip = false;
4624
4625 for (uint32_t i = 0; i < createInfoCount; i++) {
4626 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4627 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004628 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004629 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4630 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4631 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4632 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004633 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004634
4635 const auto *pipeline_cache_contol_features =
4636 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4637 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4638 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4639 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4640 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4641 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4642 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4643 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4644 }
4645 }
4646
sourav parmarf4a78252020-04-10 13:04:21 -07004647 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4648 skip |=
4649 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4650 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4651 }
4652 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4653 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4654 skip |=
4655 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4656 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4657 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4658 }
4659 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4660 if (pCreateInfos[i].basePipelineIndex != -1) {
4661 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4662 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4663 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4664 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4665 "and pCreateInfos->basePipelineIndex is not -1.");
4666 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004667 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4668 skip |=
4669 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4670 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4671 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4672 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4673 "that element.");
4674 }
sourav parmarf4a78252020-04-10 13:04:21 -07004675 }
4676 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004677 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004678 skip |=
4679 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4680 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4681 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4682 "commands pCreateInfos parameter.");
4683 }
4684 } else {
4685 if (pCreateInfos[i].basePipelineIndex != -1) {
4686 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4687 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4688 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4689 }
4690 }
4691 }
4692 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4693 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4694 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4695 }
4696 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4697 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4698 "vkCreateRayTracingPipelinesNV: flags must not include "
4699 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4700 }
4701 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4702 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4703 "vkCreateRayTracingPipelinesNV: flags must not include "
4704 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4705 }
4706 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4707 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4708 "vkCreateRayTracingPipelinesNV: flags must not include "
4709 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4710 }
4711 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4712 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4713 "vkCreateRayTracingPipelinesNV: flags must not include "
4714 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4715 }
4716 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4717 skip |= LogError(
4718 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4719 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4720 }
4721 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4722 skip |= LogError(
4723 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4724 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4725 }
Peter Chen85366392019-05-14 15:20:11 -04004726 }
4727
4728 return skip;
4729}
4730
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004731bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4732 uint32_t createInfoCount,
4733 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4734 const VkAllocationCallbacks *pAllocator,
4735 VkPipeline *pPipelines) const {
4736 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004737 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4738 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4739 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4740 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4741 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004742 for (uint32_t i = 0; i < createInfoCount; i++) {
4743 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4744 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4745 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4746 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4747 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4748 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4749 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4750 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004751 const auto *pipeline_cache_contol_features =
4752 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4753 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4754 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4755 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4756 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4757 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4758 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4759 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4760 }
4761 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004762 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4763 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4764 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4765 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4766 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4767 }
4768 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4769 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4770 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4771 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4772 }
4773 }
4774
sourav parmarf4a78252020-04-10 13:04:21 -07004775 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4776 skip |=
4777 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4778 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4779 }
4780 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4781 if (pCreateInfos[i].pLibraryInterface == NULL)
4782 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4783 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4784 }
4785 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4786 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4787 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4788 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4789 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4790 skip |= LogError(
4791 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4792 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4793 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4794 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4795 "must not be VK_SHADER_UNUSED_KHR");
4796 }
4797 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4798 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4799 skip |= LogError(
4800 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4801 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4802 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4803 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4804 "element must not be VK_SHADER_UNUSED_KHR");
4805 }
4806 }
4807 }
4808 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4809 if (pCreateInfos[i].basePipelineIndex != -1) {
4810 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4811 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4812 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4813 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4814 "and pCreateInfos->basePipelineIndex is not -1.");
4815 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004816 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4817 skip |=
4818 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4819 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4820 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4821 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4822 "element.");
4823 }
sourav parmarf4a78252020-04-10 13:04:21 -07004824 }
4825 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004826 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004827 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4828 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4829 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4830 "commands pCreateInfos parameter %d.",
4831 pCreateInfos[i].basePipelineIndex, createInfoCount);
4832 }
4833 } else {
4834 if (pCreateInfos[i].basePipelineIndex != -1) {
4835 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4836 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4837 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4838 }
4839 }
4840 }
4841 if (pCreateInfos[i].libraries.libraryCount == 0) {
4842 if (pCreateInfos[i].stageCount == 0) {
4843 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4844 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4845 }
4846 if (pCreateInfos[i].groupCount == 0) {
4847 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4848 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4849 }
4850 } else {
4851 if (pCreateInfos[i].pLibraryInterface == NULL) {
4852 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4853 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4854 }
4855 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004856 }
4857
4858 return skip;
4859}
4860
Mike Schuchardt21638df2019-03-16 10:52:02 -07004861#ifdef VK_USE_PLATFORM_WIN32_KHR
4862bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4863 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004864 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004865 bool skip = false;
4866 if (!device_extensions.vk_khr_swapchain)
4867 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4868 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4869 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4870 if (!device_extensions.vk_khr_surface)
4871 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4872 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4873 skip |=
4874 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4875 if (!device_extensions.vk_ext_full_screen_exclusive)
4876 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4877 skip |= validate_struct_type(
4878 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4879 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4880 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4881 if (pSurfaceInfo != NULL) {
4882 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4883 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4884 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4885
4886 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4887 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4888 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4889 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004890 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4891 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004892
4893 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4894 }
4895 return skip;
4896}
4897#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004898
4899bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4900 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004901 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004902 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4903 bool skip = false;
4904 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4905 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4906 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4907 }
4908 return skip;
4909}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004910
4911bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004912 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004913 bool skip = false;
4914
4915 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004916 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4917 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004918 }
4919
4920 return skip;
4921}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004922
4923bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004924 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004925 bool skip = false;
4926
4927 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004928 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4929 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004930 }
4931
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004932 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004933 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004934 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4935 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004936 }
4937
4938 return skip;
4939}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004940
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004941bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4942 uint32_t bindingCount, const VkBuffer *pBuffers,
4943 const VkDeviceSize *pOffsets) const {
4944 bool skip = false;
4945 if (firstBinding > device_limits.maxVertexInputBindings) {
4946 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4947 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4948 device_limits.maxVertexInputBindings);
4949 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4950 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4951 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4952 "maxVertexInputBindings (%u)",
4953 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4954 }
4955
Jeff Bolz165818a2020-05-08 11:19:03 -05004956 for (uint32_t i = 0; i < bindingCount; ++i) {
4957 if (pBuffers[i] == VK_NULL_HANDLE) {
4958 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4959 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4960 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4961 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4962 } else {
4963 if (pOffsets[i] != 0) {
4964 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4965 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4966 }
4967 }
4968 }
4969 }
4970
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004971 return skip;
4972}
4973
Mark Lobodzinski84988402019-09-11 15:27:30 -06004974bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004975 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004976 bool skip = false;
4977 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004978 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4979 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004980 }
4981 return skip;
4982}
4983
4984bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004985 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004986 bool skip = false;
4987 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004988 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4989 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004990 }
4991 return skip;
4992}
Petr Kraus3d720392019-11-13 02:52:39 +01004993
4994bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4995 VkSemaphore semaphore, VkFence fence,
4996 uint32_t *pImageIndex) const {
4997 bool skip = false;
4998
4999 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005000 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5001 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005002 }
5003
5004 return skip;
5005}
5006
5007bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5008 uint32_t *pImageIndex) const {
5009 bool skip = false;
5010
5011 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005012 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5013 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005014 }
5015
5016 return skip;
5017}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005018
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005019bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5020 uint32_t firstBinding, uint32_t bindingCount,
5021 const VkBuffer *pBuffers,
5022 const VkDeviceSize *pOffsets,
5023 const VkDeviceSize *pSizes) const {
5024 bool skip = false;
5025
5026 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5027 for (uint32_t i = 0; i < bindingCount; ++i) {
5028 if (pOffsets[i] & 3) {
5029 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5030 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5031 }
5032 }
5033
5034 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5035 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5036 "%s: The firstBinding(%" PRIu32
5037 ") index is greater than or equal to "
5038 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5039 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5040 }
5041
5042 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5043 skip |=
5044 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5045 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5046 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5047 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5048 }
5049
5050 for (uint32_t i = 0; i < bindingCount; ++i) {
5051 // pSizes is optional and may be nullptr.
5052 if (pSizes != nullptr) {
5053 if (pSizes[i] != VK_WHOLE_SIZE &&
5054 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5055 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5056 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5057 ") is not VK_WHOLE_SIZE and is greater than "
5058 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5059 cmd_name, i, pSizes[i]);
5060 }
5061 }
5062 }
5063
5064 return skip;
5065}
5066
5067bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5068 uint32_t firstCounterBuffer,
5069 uint32_t counterBufferCount,
5070 const VkBuffer *pCounterBuffers,
5071 const VkDeviceSize *pCounterBufferOffsets) const {
5072 bool skip = false;
5073
5074 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5075 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5076 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5077 "%s: The firstCounterBuffer(%" PRIu32
5078 ") index is greater than or equal to "
5079 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5080 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5081 }
5082
5083 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5084 skip |=
5085 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5086 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5087 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5088 cmd_name, firstCounterBuffer, counterBufferCount,
5089 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5090 }
5091
5092 return skip;
5093}
5094
5095bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5096 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5097 const VkBuffer *pCounterBuffers,
5098 const VkDeviceSize *pCounterBufferOffsets) const {
5099 bool skip = false;
5100
5101 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5102 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5103 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5104 "%s: The firstCounterBuffer(%" PRIu32
5105 ") index is greater than or equal to "
5106 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5107 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5108 }
5109
5110 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5111 skip |=
5112 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5113 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5114 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5115 cmd_name, firstCounterBuffer, counterBufferCount,
5116 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5117 }
5118
5119 return skip;
5120}
5121
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005122bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5123 uint32_t firstInstance, VkBuffer counterBuffer,
5124 VkDeviceSize counterBufferOffset,
5125 uint32_t counterOffset, uint32_t vertexStride) const {
5126 bool skip = false;
5127
5128 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005129 skip |= LogError(
5130 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005131 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5132 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5133 }
5134
5135 return skip;
5136}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005137
5138bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5139 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5140 const VkAllocationCallbacks *pAllocator,
5141 VkSamplerYcbcrConversion *pYcbcrConversion,
5142 const char *apiName) const {
5143 bool skip = false;
5144
5145 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005146 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005147 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005148 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5149 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5150 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005151 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005152 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005153 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005154
sfricke-samsung1a72f942020-07-25 12:09:18 -07005155 const VkFormat format = pCreateInfo->format;
sfricke-samsung83d98122020-07-04 06:21:15 -07005156 const VkComponentMapping components = pCreateInfo->components;
5157 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
sfricke-samsung1a72f942020-07-25 12:09:18 -07005158 if (FormatIsXChromaSubsampled(format) == true) {
sfricke-samsung83d98122020-07-04 06:21:15 -07005159 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5160 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
5161 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5162 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005163 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
sfricke-samsung83d98122020-07-04 06:21:15 -07005164 }
5165
5166 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5167 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5168 skip |=
5169 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5170 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5171 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005172 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
sfricke-samsung83d98122020-07-04 06:21:15 -07005173 }
5174
5175 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5176 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5177 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
5178 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5179 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005180 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
sfricke-samsung83d98122020-07-04 06:21:15 -07005181 }
5182
5183 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5184 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5185 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
5186 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5187 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005188 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
sfricke-samsung83d98122020-07-04 06:21:15 -07005189 }
5190
5191 // If one is identity, both need to be
5192 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5193 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5194 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5195 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
5196 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5197 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005198 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5199 string_VkComponentSwizzle(components.b));
5200 }
5201 }
5202
5203 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5204 // Checks same VU multiple ways in order to give a more useful error message
5205 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5206 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5207 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5208 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5209 skip |=
5210 LogError(device, vuid,
5211 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5212 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5213 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5214 string_VkComponentSwizzle(components.b));
5215 }
5216
5217 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5218 // 4 channel format = no issue
5219 // 3 = no [a]
5220 // 2 = no [b,a]
5221 // 1 = no [g,b,a]
5222 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5223 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5224
5225 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5226 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5227 skip |= LogError(device, vuid,
5228 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5229 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5230 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5231 string_VkComponentSwizzle(components.b));
5232 } else if ((channels < 3) &&
5233 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5234 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5235 skip |= LogError(device, vuid,
5236 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5237 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5238 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5239 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5240 string_VkComponentSwizzle(components.b));
5241 } else if ((channels < 2) &&
5242 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5243 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5244 skip |= LogError(device, vuid,
5245 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5246 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5247 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5248 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
sfricke-samsung83d98122020-07-04 06:21:15 -07005249 string_VkComponentSwizzle(components.b));
5250 }
5251 }
5252
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005253 return skip;
5254}
5255
5256bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5257 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5258 const VkAllocationCallbacks *pAllocator,
5259 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5260 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5261 "vkCreateSamplerYcbcrConversion");
5262}
5263
5264bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5265 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5266 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5267 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5268 "vkCreateSamplerYcbcrConversionKHR");
5269}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005270
5271bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5272 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5273 bool skip = false;
5274 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5275 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5276
5277 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005278 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5279 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5280 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5281 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5282 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005283 }
5284 return skip;
5285}
sourav parmara96ab1a2020-04-25 16:28:23 -07005286
5287bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5288 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5289 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005290 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5291 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5292 skip |=
5293 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5294 "vkCopyAccelerationStructureToMemoryKHR: the "
5295 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5296 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005297 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5298 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5299 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5300 }
5301 return skip;
5302}
5303
5304bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5305 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5306 bool skip = false;
5307 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5308 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5309 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5310 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5311 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005312 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5313 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005314 skip |= LogError(
5315 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5316 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5317 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5318 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005319 return skip;
5320}
5321
5322bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5323 const char *api_name) const {
5324 bool skip = false;
5325 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5326 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5327 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5328 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5329 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5330 api_name);
5331 }
5332 return skip;
5333}
5334
5335bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5336 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5337 bool skip = false;
5338 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005339 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5340 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5341 skip |= LogError(
5342 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5343 "vkCopyAccelerationStructureKHR(): the "
5344 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5345 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005346 return skip;
5347}
5348
5349bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5350 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5351 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005352 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5353 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005354 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5355 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5356 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5357 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005358 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5359 return skip;
5360}
5361
5362bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005363 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005364 bool skip = false;
5365 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005366 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005367 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005368 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005369 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5370 }
5371 return skip;
5372}
5373
5374bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5375 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5376 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005377 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5378 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5379 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5380 skip |=
5381 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5382 "vkCopyMemoryToAccelerationStructureKHR() :the "
5383 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5384 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005385 return skip;
5386}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005387
sourav parmara96ab1a2020-04-25 16:28:23 -07005388bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5389 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5390 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005391 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5392 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005393 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5394 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5395 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5396 }
sourav parmar83c31b12020-05-06 12:30:54 -07005397 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5398 return skip;
5399}
5400bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5401 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5402 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5403 bool skip = false;
5404 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5405 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5406 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5407 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5408 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5409 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5410 }
5411 return skip;
5412}
5413bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5414 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5415 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5416 bool skip = false;
5417 if (dataSize < accelerationStructureCount * stride) {
5418 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5419 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5420 "accelerationStructureCount (%d) *stride(%zu).",
5421 dataSize, accelerationStructureCount, stride);
5422 }
5423 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5424 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5425 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5426 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5427 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5428 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5429 }
5430 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5431 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5432 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5433 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5434 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5435 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5436 stride);
5437 }
5438 }
5439 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5440 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5441 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5442 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5443 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5444 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5445 stride);
5446 }
5447 }
5448 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5449 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5450 skip |=
5451 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5452 "vkWriteAccelerationStructuresPropertiesKHR: the "
5453 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5454 "feature must be enabled ");
5455 }
5456 return skip;
5457}
5458bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5459 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5460 bool skip = false;
5461 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5462 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5463 skip |= LogError(device,
5464 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5465 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5466 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5467 "must be enabled to call this function.");
5468 }
5469 return skip;
5470}
5471
5472bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5473 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5474 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5475 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5476 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5477 uint32_t width, uint32_t height, uint32_t depth) const {
5478 bool skip = false;
5479 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5480 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5481 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5482 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5483 }
5484 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5485 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5486 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5487 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5488 }
5489 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5490 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5491 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5492 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5493 }
5494 // hitShader
5495 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5496 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5497 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5498 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5499 }
5500 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5501 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5502 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5503 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5504 }
5505 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5506 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5507 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5508 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5509 }
5510
5511 // missShader
5512 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5513 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5514 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5515 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5516 }
5517 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5518 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5519 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5520 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5521 }
5522 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5523 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5524 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5525 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5526 }
5527
5528 // raygenShader
5529 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5530 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5531 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5532 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5533 }
5534 return skip;
5535}
5536
5537bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5538 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5539 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5540 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5541 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5542 VkBuffer buffer, VkDeviceSize offset) const {
5543 bool skip = false;
5544 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5545 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5546 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5547 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5548 "feature must be enabled.");
5549 }
5550 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5551 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5552 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5553 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5554 }
5555 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5556 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5557 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5558 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5559 }
5560 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5561 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5562 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5563 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5564 }
5565 // hitShader
5566 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5567 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5568 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5569 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5570 }
5571 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5572 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5573 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5574 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5575 }
5576 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5577 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5578 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5579 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5580 }
5581
5582 // missShader
5583 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5584 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5585 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5586 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5587 }
5588 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5589 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5590 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5591 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5592 }
5593 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5594 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5595 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5596 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5597 }
5598
5599 // raygenShader
5600 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5601 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5602 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5603 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5604 }
5605 return skip;
5606}
5607bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5608 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5609 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5610 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5611 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5612 uint32_t width, uint32_t height, uint32_t depth) const {
5613 bool skip = false;
5614 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5615 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5616 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5617 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5618 }
5619 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5620 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5621 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5622 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5623 }
5624 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5625 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5626 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5627 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5628 }
5629
5630 // hitShader
5631 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5632 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5633 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5634 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5635 }
5636 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5637 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5638 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5639 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5640 }
5641 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5642 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5643 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5644 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5645 }
5646
5647 // missShader
5648 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5649 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5650 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5651 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5652 }
5653 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5654 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5655 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5656 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5657 }
5658 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5659 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5660 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5661 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5662 }
5663
5664 // raygenShader
5665 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5666 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5667 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005668 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5669 }
5670 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5671 skip |=
5672 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5673 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5674 }
5675 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5676 skip |=
5677 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5678 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5679 }
5680 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5681 skip |=
5682 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5683 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005684 }
5685 return skip;
5686}
5687
5688bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5689 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5690 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5691 bool skip = false;
5692 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5693 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5694 skip |= LogError(
5695 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5696 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5697 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5698 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005699 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5700 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005701 skip |=
5702 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5703 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5704 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5705 }
5706 return false;
5707}
5708
5709bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5710 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5711 bool skip = false;
5712 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5713 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5714 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5715 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5716 }
5717 return skip;
5718}
5719
5720bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5721 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5722 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5723 bool skip = false;
5724 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5725 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005726 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5727 "vkBuildAccelerationStructureKHR: The "
5728 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5729 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005730 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005731 return skip;
5732}
sourav parmara24fb7b2020-05-26 10:50:04 -07005733bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5734 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5735 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5736 bool skip = false;
5737 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005738 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5739 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005740 skip |=
5741 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5742 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5743 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5744 }
5745 }
5746 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005747}
Piers Daniell39842ee2020-07-10 16:42:33 -06005748
5749bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5750 const VkViewport *pViewports) const {
5751 bool skip = false;
5752
5753 if (!physical_device_features.multiViewport) {
5754 if (viewportCount != 1) {
5755 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5756 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5757 ") is not 1.",
5758 viewportCount);
5759 }
5760 } else { // multiViewport enabled
5761 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5762 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5763 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5764 ") must "
5765 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5766 viewportCount, device_limits.maxViewports);
5767 }
5768 }
5769
5770 if (pViewports) {
5771 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5772 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5773 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5774 skip |= manual_PreCallValidateViewport(
5775 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5776 }
5777 }
5778
5779 return skip;
5780}
5781
5782bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5783 const VkRect2D *pScissors) const {
5784 bool skip = false;
5785
5786 if (!physical_device_features.multiViewport) {
5787 if (scissorCount != 1) {
5788 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5789 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5790 ") must "
5791 "be 1 when the multiViewport feature is disabled.",
5792 scissorCount);
5793 }
5794 } else { // multiViewport enabled
5795 if (scissorCount == 0) {
5796 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5797 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5798 ") must "
5799 "be great than zero.",
5800 scissorCount);
5801 } else if (scissorCount > device_limits.maxViewports) {
5802 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5803 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5804 ") must "
5805 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5806 scissorCount, device_limits.maxViewports);
5807 }
5808 }
5809
5810 if (pScissors) {
5811 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5812 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5813
5814 if (scissor.offset.x < 0) {
5815 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5816 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5817 scissor.offset.x);
5818 }
5819
5820 if (scissor.offset.y < 0) {
5821 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5822 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5823 scissor.offset.y);
5824 }
5825
5826 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5827 if (x_sum > INT32_MAX) {
5828 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5829 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5830 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5831 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5832 }
5833
5834 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5835 if (y_sum > INT32_MAX) {
5836 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5837 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5838 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5839 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5840 }
5841 }
5842 }
5843
5844 return skip;
5845}
5846
5847bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5848 uint32_t bindingCount, const VkBuffer *pBuffers,
5849 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5850 const VkDeviceSize *pStrides) const {
5851 bool skip = false;
5852 if (firstBinding >= device_limits.maxVertexInputBindings) {
5853 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5854 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5855 firstBinding, device_limits.maxVertexInputBindings);
5856 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5857 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5858 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5859 "maxVertexInputBindings (%u)",
5860 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5861 }
5862
5863 for (uint32_t i = 0; i < bindingCount; ++i) {
5864 if (pBuffers[i] == VK_NULL_HANDLE) {
5865 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5866 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5867 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5868 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5869 } else {
5870 if (pOffsets[i] != 0) {
5871 skip |=
5872 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5873 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5874 }
5875 }
5876 }
5877 if (pStrides) {
5878 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5879 skip |=
5880 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5881 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5882 pStrides[i], device_limits.maxVertexInputBindingStride);
5883 }
5884 }
5885 }
5886
5887 return skip;
5888}