blob: a338644af7bb3b81f6982c0b738d8e2bae9fba8c [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);
Jeff Bolz165818a2020-05-08 11:19:03 -0500306 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
307 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
308 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
309 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
310 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
311 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700312 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
313 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
314 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
315 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
316 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
317 "must also be VK_TRUE.");
318 }
Locke77fad1c2019-04-16 13:09:03 -0600319 auto vertex_attribute_divisor_features =
320 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600321 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
322 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
323 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
324 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600325 }
326
Tony-LunarG28017bc2020-01-23 14:40:25 -0700327 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
328 if (vulkan_11_features) {
329 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
330 while (current) {
331 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
335 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
336 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700337 skip |= LogError(
338 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700339 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
340 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
341 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
342 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
343 break;
344 }
345 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
346 }
347 }
348
349 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
350 if (vulkan_12_features) {
351 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
352 while (current) {
353 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
364 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
365 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700366 skip |= LogError(
367 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700368 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
369 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
370 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
371 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
372 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
373 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
374 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
375 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
376 break;
377 }
378 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
379 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700380 // Check features are enabled if matching extension is passed in as well
381 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
382 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
383 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
384 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
385 skip |= LogError(
386 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
387 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
388 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
389 }
390 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
391 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
392 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
393 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
394 "is not VK_TRUE.",
395 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
396 }
397 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
398 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
399 skip |= LogError(
400 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
401 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
402 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
403 }
404 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
405 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
406 skip |= LogError(
407 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
408 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
409 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
410 }
411 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
412 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
413 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
414 skip |=
415 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
416 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
417 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
418 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
419 }
420 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700421 }
422
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600423 // Validate pCreateInfo->pQueueCreateInfos
424 if (pCreateInfo->pQueueCreateInfos) {
425 std::unordered_set<uint32_t> set;
426
427 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700428 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
429 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600430 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700431 skip |=
432 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
433 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
434 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
435 "index value.",
436 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600437 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700438 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
439 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
440 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
441 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600442 } else {
443 set.insert(requested_queue_family);
444 }
445
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700446 if (queue_create_info.pQueuePriorities != nullptr) {
447 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
448 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600449 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700450 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
451 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
452 "] (=%f) is not between 0 and 1 (inclusive).",
453 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600454 }
455 }
456 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700457
458 // Need to know if protectedMemory feature is passed in preCall to creating the device
459 VkBool32 protectedMemory = VK_FALSE;
460 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
461 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
462 if (protected_features) {
463 protectedMemory = protected_features->protectedMemory;
464 } else if (vulkan_11_features) {
465 protectedMemory = vulkan_11_features->protectedMemory;
466 }
467 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
468 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
469 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
470 "protectedMemory feature being set as well.");
471 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600472 }
473 }
474
sfricke-samsung30a57412020-05-15 21:14:54 -0700475 // feature dependencies for VK_KHR_variable_pointers
476 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
477 VkBool32 variablePointers = VK_FALSE;
478 VkBool32 variablePointersStorageBuffer = VK_FALSE;
479 if (vulkan_11_features) {
480 variablePointers = vulkan_11_features->variablePointers;
481 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
482 } else if (variable_pointers_features) {
483 variablePointers = variable_pointers_features->variablePointers;
484 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
485 }
486 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
487 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
488 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
489 }
490
sfricke-samsungfd76c342020-05-29 23:13:43 -0700491 // feature dependencies for VK_KHR_multiview
492 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
493 VkBool32 multiview = VK_FALSE;
494 VkBool32 multiviewGeometryShader = VK_FALSE;
495 VkBool32 multiviewTessellationShader = VK_FALSE;
496 if (vulkan_11_features) {
497 multiview = vulkan_11_features->multiview;
498 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
499 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
500 } else if (multiview_features) {
501 multiview = multiview_features->multiview;
502 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
503 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
504 }
505 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
506 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
507 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
508 }
509 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
510 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
511 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
512 }
513
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600514 return skip;
515}
516
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500517bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700518 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700519 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
520 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
521 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600522 }
523
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700524 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525}
526
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700527bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500528 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100529 bool skip = false;
530
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600531 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700532 skip |=
533 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600534
535 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
536 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
537 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
538 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700539 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
540 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
541 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600542 }
543
544 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
545 // queueFamilyIndexCount uint32_t values
546 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
548 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
549 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
550 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600551 }
552 }
553
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700554 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
555 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
556 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
557 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
558 }
559
560 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
561 skip |=
562 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
563 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
564 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
565 }
566
567 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
568 skip |=
569 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
570 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
571 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
572 }
573
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600574 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
575 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
576 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
577 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700578 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
579 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
580 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600581 }
582 }
583
584 return skip;
585}
586
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700587bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500588 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600589 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590
591 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600592 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
593 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
594 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
595 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700596 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
597 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
598 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600599 }
600
601 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
602 // queueFamilyIndexCount uint32_t values
603 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
605 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
606 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
607 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600608 }
609 }
610
Dave Houlton413a6782018-05-22 13:01:54 -0600611 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700612 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600613 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600615 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700616 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617
Dave Houlton413a6782018-05-22 13:01:54 -0600618 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700619 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600620 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700621 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600622
Dave Houlton130c0212018-01-29 13:39:56 -0700623 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700624 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
625 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700626 skip |= LogError(
627 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600628 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
629 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700630 }
631
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600632 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100633 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
634 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700635 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
636 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
637 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638 }
639
640 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100641 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
642 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700643 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
644 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
645 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
646 ") are not equal.",
647 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100648 }
649
650 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700651 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
652 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
653 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
654 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100655 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600656 }
657
658 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(
660 device, "VUID-VkImageCreateInfo-imageType-00957",
661 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600662 }
663 }
664
Dave Houlton130c0212018-01-29 13:39:56 -0700665 // 3D image may have only 1 layer
666 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700667 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
668 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700669 }
670
671 // If multi-sample, validate type, usage, tiling and mip levels.
672 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
673 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600674 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
676 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700677 }
678
679 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
680 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
681 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
682 // At least one of the legal attachment bits must be set
683 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700684 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
685 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700686 }
687 // No flags other than the legal attachment bits may be set
688 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
689 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700690 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
691 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700692 }
693 }
694
Jeff Bolzef40fec2018-09-01 22:04:34 -0500695 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500697 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600698 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
699 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500700 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600701 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700702 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
703 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
704 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600705 }
706
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600707 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
709 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
710 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600711 }
712
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700713 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700714 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
715 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
716 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100717 }
718
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700719 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
720 skip |= LogError(
721 device, "VUID-VkImageCreateInfo-flags-01924",
722 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
723 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
724 }
725
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600726 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
727 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
728 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
729 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
731 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
732 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600733 }
734
735 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
736 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
737 // Linear tiling is unsupported
738 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
741 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600742 }
743
744 // Sparse 1D image isn't valid
745 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700746 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
747 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600748 }
749
750 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700751 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700752 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
753 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
754 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600755 }
756
757 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700758 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700759 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
760 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
761 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600762 }
763
764 // Multi-sample 2D image when device doesn't support it
765 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700766 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600767 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
769 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
770 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700771 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600772 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
774 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
775 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700776 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600777 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700778 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
779 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
780 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700781 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600782 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700783 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
784 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
785 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600786 }
787 }
788 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500789
Jeff Bolz9af91c52018-09-01 21:53:57 -0500790 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
791 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
793 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
794 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500795 }
796 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
798 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
799 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500800 }
801 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700802 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
803 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
804 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500805 }
806 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500807
808 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600809 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700810 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
811 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
812 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500813 }
814
Dave Houlton142c4cb2018-10-17 15:04:41 -0600815 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
817 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
818 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
819 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500820 }
821
Dave Houlton142c4cb2018-10-17 15:04:41 -0600822 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700823 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
824 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
825 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
826 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500827 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600828 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700829 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
830 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
831 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
832 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500833 }
834 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500835
sfricke-samsung8f658d42020-05-03 20:12:24 -0700836 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
837 (FormatHasDepth(pCreateInfo->format) == false)) {
838 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
839 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
840 "format must be a depth or depth/stencil format.");
841 }
842
Andrew Fobel3abeb992020-01-20 16:33:22 -0500843 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
844 if (image_stencil_struct != nullptr) {
845 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
846 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
847 // No flags other than the legal attachment bits may be set
848 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
849 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700850 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
851 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
852 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
853 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500854 }
855 }
856
857 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
858 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
859 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
860 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700861 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
862 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
863 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
864 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500865 }
866
867 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
868 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700869 LogError(device, "VUID-VkImageCreateInfo-format-02537",
870 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
871 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
872 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500873 }
874 }
875
876 if (!physical_device_features.shaderStorageImageMultisample &&
877 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
878 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
879 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700880 LogError(device, "VUID-VkImageCreateInfo-format-02538",
881 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
882 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
883 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500884 }
885
886 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
887 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700888 skip |= LogError(
889 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500890 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
891 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
892 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
893 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
894 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700895 skip |= LogError(
896 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500897 "vkCreateImage(): Depth-stencil image in which usage does not include "
898 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
899 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
900 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
901 }
902
903 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
904 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700905 skip |= LogError(
906 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500907 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
908 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
909 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
910 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
911 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700912 skip |= LogError(
913 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500914 "vkCreateImage(): Depth-stencil image in which usage does not include "
915 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
916 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
917 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
918 }
919 }
920 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700921
922 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
923 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
924 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
925 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
926 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
927 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700928
929 if (device_extensions.vk_ext_image_drm_format_modifier) {
930 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
931 const auto drm_format_mod_explict =
932 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
933 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
934 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
935 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
936 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
937 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
938 "either VkImageDrmFormatModifierListCreateInfoEXT or "
939 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
940 }
941 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
942 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
943 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
944 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
945 "in the pNext chain");
946 }
947 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200948
949 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
950 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
951 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
952 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
953 "imageType must be VK_IMAGE_TYPE_2D.");
954 }
955 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
956 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
957 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
958 "samples must be VK_SAMPLE_COUNT_1_BIT.");
959 }
960 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
961 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
962 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
963 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
964 }
965 }
966 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
967 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
968 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
969 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
970 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
971 }
972 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
973 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
974 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
975 "imageType must be VK_IMAGE_TYPE_2D.");
976 }
977 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
978 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
979 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
980 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
981 }
982 if (pCreateInfo->mipLevels != 1) {
983 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
984 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
985 pCreateInfo->mipLevels);
986 }
987 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -0700988
989 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
990 if (swapchain_create_info != nullptr) {
991 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
992 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
993 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
994 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
995 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
996 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
997
998 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
999 // also implicitly forces the check above that extent.depth is 1
1000 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1001 string_VkImageType(pCreateInfo->imageType));
1002 }
1003 if (pCreateInfo->mipLevels != 1) {
1004 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1005 pCreateInfo->mipLevels);
1006 }
1007 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1008 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1009 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1010 }
1011 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1012 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1013 base_message, string_VkImageTiling(pCreateInfo->tiling));
1014 }
1015 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1016 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1017 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1018 }
1019 const VkImageCreateFlags valid_flags =
1020 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1021 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1022 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1023 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1024 pCreateInfo->flags);
1025 }
1026 }
1027 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001028 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001029
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001030 return skip;
1031}
1032
Jeff Bolz99e3f632020-03-24 22:59:22 -05001033bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1034 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1035 bool skip = false;
1036
1037 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001038 // Validate feature set if using CUBE_ARRAY
1039 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1040 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1041 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1042 "enabling the imageCubeArray feature.");
1043 }
1044
Jeff Bolz99e3f632020-03-24 22:59:22 -05001045 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1046 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1047 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001048 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001049 pCreateInfo->subresourceRange.layerCount);
1050 }
1051 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001052 skip |= LogError(
1053 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1054 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1055 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001056 }
1057 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001058
1059 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1060 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1061 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1062 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1063 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1064 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1065 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1066 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1067 }
1068 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1069 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1070 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1071 "not an ASTC format.",
1072 string_VkFormat(pCreateInfo->format));
1073 }
1074 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001075
1076 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1077 if (ycbcr_conversion != nullptr) {
1078 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1079 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1080 skip |= LogError(
1081 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1082 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1083 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1084 "r swizzle = %s\n"
1085 "g swizzle = %s\n"
1086 "b swizzle = %s\n"
1087 "a swizzle = %s\n",
1088 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1089 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1090 }
1091 }
1092 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001093 }
1094 return skip;
1095}
1096
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001097bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001098 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001099 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001100
1101 // Note: for numerical correctness
1102 // - float comparisons should expect NaN (comparison always false).
1103 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1104
1105 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001106 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001107 if (v1_f <= 0.0f) return true;
1108
1109 float intpart;
1110 const float fract = modff(v1_f, &intpart);
1111
1112 assert(std::numeric_limits<float>::radix == 2);
1113 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1114 if (intpart >= u32_max_plus1) return false;
1115
1116 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1117 if (v1_u32 < v2_u32)
1118 return true;
1119 else if (v1_u32 == v2_u32 && fract == 0.0f)
1120 return true;
1121 else
1122 return false;
1123 };
1124
1125 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1126 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1127 return (v1_f <= v2_f);
1128 };
1129
1130 // width
1131 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001132 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001133
1134 if (!(viewport.width > 0.0f)) {
1135 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001136 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1137 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001138 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1139 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001140 skip |= LogError(object, "VUID-VkViewport-width-01771",
1141 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1142 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001143 } 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 -07001144 skip |= LogWarning(object, kVUID_PVError_NONE,
1145 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1146 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1147 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001148 }
1149
1150 // height
1151 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001152 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001153 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001154
1155 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1156 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001157 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1158 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001159 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1160 height_healthy = false;
1161
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001162 skip |= LogError(object, "VUID-VkViewport-height-01773",
1163 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1164 ").",
1165 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001166 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1167 height_healthy = false;
1168
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001169 skip |= LogWarning(
1170 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001171 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001172 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001173 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001174 }
1175
1176 // x
1177 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001178 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001179 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001180 skip |= LogError(object, "VUID-VkViewport-x-01774",
1181 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1182 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001183 }
1184
1185 // x + width
1186 if (x_healthy && width_healthy) {
1187 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001188 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001189 skip |= LogError(
1190 object, "VUID-VkViewport-x-01232",
1191 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1192 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1193 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001194 }
1195 }
1196
1197 // y
1198 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001199 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001200 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001201 skip |= LogError(object, "VUID-VkViewport-y-01775",
1202 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1203 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001204 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001205 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001206 skip |= LogError(object, "VUID-VkViewport-y-01776",
1207 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1208 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001209 }
1210
1211 // y + height
1212 if (y_healthy && height_healthy) {
1213 const float boundary = viewport.y + viewport.height;
1214
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001215 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001216 skip |= LogError(object, "VUID-VkViewport-y-01233",
1217 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1218 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1219 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001220 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001221 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001222 LogError(object, "VUID-VkViewport-y-01777",
1223 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1224 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1225 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001226 }
1227 }
1228
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001229 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001230 // minDepth
1231 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001232 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001233
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001234 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1235 "[0.0, 1.0] range.",
1236 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001237 }
1238
1239 // maxDepth
1240 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001241 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001242
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001243 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1244 "[0.0, 1.0] range.",
1245 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001246 }
1247 }
1248
1249 return skip;
1250}
1251
Dave Houlton142c4cb2018-10-17 15:04:41 -06001252struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001253 VkShadingRatePaletteEntryNV shadingRate;
1254 uint32_t width;
1255 uint32_t height;
1256};
1257
1258// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001259static SampleOrderInfo sampleOrderInfos[] = {
1260 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1261 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1262 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1263 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1264 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1265 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001266};
1267
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001268bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001269 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001270
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001271 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001272 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001273 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001274 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001275 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001276 break;
1277 }
1278 }
1279
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001280 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001281 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1282 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1283 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001284 return skip;
1285 }
1286
Dave Houlton142c4cb2018-10-17 15:04:41 -06001287 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001288 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001289 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1290 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1291 ") must "
1292 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1293 "is set in framebufferNoAttachmentsSampleCounts.",
1294 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001295 }
1296
Jeff Bolz9af91c52018-09-01 21:53:57 -05001297 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001298 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1299 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1300 ") must "
1301 "be equal to the product of sampleCount (=%" PRIu32
1302 "), the fragment width for shadingRate "
1303 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1304 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001305 }
1306
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001307 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001308 skip |= LogError(
1309 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001310 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1311 ") must "
1312 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001313 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001314 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001315
1316 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001317 // the first width*height*sampleCount bits to all be set. Note: There is no
1318 // guarantee that 64 bits is enough, but practically it's unlikely for an
1319 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001320 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001321 uint64_t sampleLocationsMask = 0;
1322 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1323 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1324 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001325 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1326 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001327 }
1328 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001329 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1330 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001331 }
1332 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001333 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1334 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001335 }
1336 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1337 sampleLocationsMask |= 1ULL << idx;
1338 }
1339
1340 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1341 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001342 skip |= LogError(
1343 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001344 "The array pSampleLocations must contain exactly one entry for "
1345 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001346 }
1347
1348 return skip;
1349}
1350
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001351bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1352 uint32_t createInfoCount,
1353 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1354 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001355 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001356 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001357
1358 if (pCreateInfos != nullptr) {
1359 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001360 bool has_dynamic_viewport = false;
1361 bool has_dynamic_scissor = false;
1362 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001363 bool has_dynamic_depth_bias = false;
1364 bool has_dynamic_blend_constant = false;
1365 bool has_dynamic_depth_bounds = false;
1366 bool has_dynamic_stencil_compare = false;
1367 bool has_dynamic_stencil_write = false;
1368 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001369 bool has_dynamic_viewport_w_scaling_nv = false;
1370 bool has_dynamic_discard_rectangle_ext = false;
1371 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001372 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001373 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001374 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001375 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001376 bool has_dynamic_cull_mode = false;
1377 bool has_dynamic_front_face = false;
1378 bool has_dynamic_primitive_topology = false;
1379 bool has_dynamic_viewport_with_count = false;
1380 bool has_dynamic_scissor_with_count = false;
1381 bool has_dynamic_vertex_input_binding_stride = false;
1382 bool has_dynamic_depth_test_enable = false;
1383 bool has_dynamic_depth_write_enable = false;
1384 bool has_dynamic_depth_compare_op = false;
1385 bool has_dynamic_depth_bounds_test_enable = false;
1386 bool has_dynamic_stencil_test_enable = false;
1387 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001388 if (pCreateInfos[i].pDynamicState != nullptr) {
1389 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1390 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1391 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001392 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1393 if (has_dynamic_viewport == true) {
1394 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1395 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1396 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1397 i);
1398 }
1399 has_dynamic_viewport = true;
1400 }
1401 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1402 if (has_dynamic_scissor == true) {
1403 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1404 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1405 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1406 i);
1407 }
1408 has_dynamic_scissor = true;
1409 }
1410 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1411 if (has_dynamic_line_width == true) {
1412 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1413 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1414 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1415 i);
1416 }
1417 has_dynamic_line_width = true;
1418 }
1419 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1420 if (has_dynamic_depth_bias == true) {
1421 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1422 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1423 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1424 i);
1425 }
1426 has_dynamic_depth_bias = true;
1427 }
1428 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1429 if (has_dynamic_blend_constant == true) {
1430 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1431 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1432 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1433 i);
1434 }
1435 has_dynamic_blend_constant = true;
1436 }
1437 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1438 if (has_dynamic_depth_bounds == true) {
1439 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1440 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1441 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1442 i);
1443 }
1444 has_dynamic_depth_bounds = true;
1445 }
1446 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1447 if (has_dynamic_stencil_compare == true) {
1448 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1449 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1450 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1451 i);
1452 }
1453 has_dynamic_stencil_compare = true;
1454 }
1455 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1456 if (has_dynamic_stencil_write == true) {
1457 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1458 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1459 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1460 i);
1461 }
1462 has_dynamic_stencil_write = true;
1463 }
1464 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1465 if (has_dynamic_stencil_reference == true) {
1466 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1467 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1468 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1469 i);
1470 }
1471 has_dynamic_stencil_reference = true;
1472 }
1473 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1474 if (has_dynamic_viewport_w_scaling_nv == true) {
1475 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1476 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1477 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1478 i);
1479 }
1480 has_dynamic_viewport_w_scaling_nv = true;
1481 }
1482 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1483 if (has_dynamic_discard_rectangle_ext == true) {
1484 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1485 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1486 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1487 i);
1488 }
1489 has_dynamic_discard_rectangle_ext = true;
1490 }
1491 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1492 if (has_dynamic_sample_locations_ext == true) {
1493 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1494 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1495 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1496 i);
1497 }
1498 has_dynamic_sample_locations_ext = true;
1499 }
1500 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1501 if (has_dynamic_exclusive_scissor_nv == true) {
1502 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1503 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1504 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1505 i);
1506 }
1507 has_dynamic_exclusive_scissor_nv = true;
1508 }
1509 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1510 if (has_dynamic_shading_rate_palette_nv == true) {
1511 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1512 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1513 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1514 i);
1515 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001516 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001517 }
1518 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1519 if (has_dynamic_viewport_course_sample_order_nv == true) {
1520 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1521 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1522 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1523 i);
1524 }
1525 has_dynamic_viewport_course_sample_order_nv = true;
1526 }
1527 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1528 if (has_dynamic_line_stipple == true) {
1529 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1530 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1531 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1532 i);
1533 }
1534 has_dynamic_line_stipple = true;
1535 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001536 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1537 if (has_dynamic_cull_mode) {
1538 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1539 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1540 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1541 i);
1542 }
1543 has_dynamic_cull_mode = true;
1544 }
1545 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1546 if (has_dynamic_front_face) {
1547 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1548 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1549 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1550 i);
1551 }
1552 has_dynamic_front_face = true;
1553 }
1554 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1555 if (has_dynamic_primitive_topology) {
1556 skip |= LogError(
1557 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1558 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1559 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1560 i);
1561 }
1562 has_dynamic_primitive_topology = true;
1563 }
1564 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1565 if (has_dynamic_viewport_with_count) {
1566 skip |= LogError(
1567 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1568 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1569 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1570 i);
1571 }
1572 has_dynamic_viewport_with_count = true;
1573 }
1574 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1575 if (has_dynamic_scissor_with_count) {
1576 skip |= LogError(
1577 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1578 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1579 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1580 i);
1581 }
1582 has_dynamic_scissor_with_count = true;
1583 }
1584 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1585 if (has_dynamic_vertex_input_binding_stride) {
1586 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1587 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1588 "listed twice in the "
1589 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1590 i);
1591 }
1592 has_dynamic_vertex_input_binding_stride = true;
1593 }
1594 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1595 if (has_dynamic_depth_test_enable) {
1596 skip |= LogError(
1597 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1598 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1599 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1600 i);
1601 }
1602 has_dynamic_depth_test_enable = true;
1603 }
1604 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1605 if (has_dynamic_depth_write_enable) {
1606 skip |= LogError(
1607 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1608 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1609 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1610 i);
1611 }
1612 has_dynamic_depth_write_enable = true;
1613 }
1614 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1615 if (has_dynamic_depth_compare_op) {
1616 skip |=
1617 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1618 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1619 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1620 i);
1621 }
1622 has_dynamic_depth_compare_op = true;
1623 }
1624 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1625 if (has_dynamic_depth_bounds_test_enable) {
1626 skip |= LogError(
1627 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1628 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1629 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1630 i);
1631 }
1632 has_dynamic_depth_bounds_test_enable = true;
1633 }
1634 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1635 if (has_dynamic_stencil_test_enable) {
1636 skip |= LogError(
1637 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1638 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1639 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1640 i);
1641 }
1642 has_dynamic_stencil_test_enable = true;
1643 }
1644 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1645 if (has_dynamic_stencil_op) {
1646 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1647 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1648 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1649 i);
1650 }
1651 has_dynamic_stencil_op = true;
1652 }
Petr Kraus299ba622017-11-24 03:09:03 +01001653 }
1654 }
1655
Peter Chen85366392019-05-14 15:20:11 -04001656 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1657 if ((feedback_struct != nullptr) &&
1658 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001659 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1660 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1661 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1662 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1663 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001664 }
1665
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001666 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001667
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001668 // Collect active stages and other information
1669 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001670 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001671 bool has_eval = false;
1672 bool has_control = false;
1673 if (pCreateInfos[i].pStages != nullptr) {
1674 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1675 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1676
1677 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1678 has_control = true;
1679 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1680 has_eval = true;
1681 }
1682
1683 skip |= validate_string(
1684 "vkCreateGraphicsPipelines",
1685 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1686 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1687 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001688 }
1689
1690 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1691 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1692 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1693 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1694 pCreateInfos[i].pTessellationState,
1695 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1696 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1697
1698 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1699 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1700
1701 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1702 "VkPipelineTessellationDomainOriginStateCreateInfo",
1703 pCreateInfos[i].pTessellationState->pNext,
1704 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1705 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001706 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1707 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001708
1709 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1710 pCreateInfos[i].pTessellationState->flags,
1711 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1712 }
1713
1714 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1715 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1716 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1717 pCreateInfos[i].pInputAssemblyState,
1718 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1719 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1720
1721 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1722 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001723 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001724
1725 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1726 pCreateInfos[i].pInputAssemblyState->flags,
1727 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1728
1729 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1730 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1731 pCreateInfos[i].pInputAssemblyState->topology,
1732 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1733
1734 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1735 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1736 }
1737
1738 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001739 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001740
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001741 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001742 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1743 "vkCreateGraphicsPipelines: pararameter "
1744 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1745 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001746 }
1747
1748 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1749 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1750 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1751 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1752 pCreateInfos[i].pVertexInputState->pNext, 1,
1753 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001754 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1755 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001756 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1757 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001758 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001759 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1760 skip |=
1761 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1762 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1763 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1764 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1765 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1766
1767 skip |= validate_array(
1768 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1769 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1770 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1771 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1772
1773 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1774 for (uint32_t vertexBindingDescriptionIndex = 0;
1775 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1776 ++vertexBindingDescriptionIndex) {
1777 skip |= validate_ranged_enum(
1778 "vkCreateGraphicsPipelines",
1779 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1780 AllVkVertexInputRateEnums,
1781 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1782 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1783 }
1784 }
1785
1786 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1787 for (uint32_t vertexAttributeDescriptionIndex = 0;
1788 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1789 ++vertexAttributeDescriptionIndex) {
1790 skip |= validate_ranged_enum(
1791 "vkCreateGraphicsPipelines",
1792 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1793 AllVkFormatEnums,
1794 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1795 "VUID-VkVertexInputAttributeDescription-format-parameter");
1796 }
1797 }
1798
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001799 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001800 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1801 "vkCreateGraphicsPipelines: pararameter "
1802 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1803 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1804 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001805 }
1806
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001807 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001808 skip |=
1809 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1810 "vkCreateGraphicsPipelines: pararameter "
1811 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1812 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1813 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001814 }
1815
1816 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001817 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1818 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001819 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1820 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001821 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1822 "vkCreateGraphicsPipelines: parameter "
1823 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1824 "(%" PRIu32 ") is not distinct.",
1825 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001826 }
1827 vertex_bindings.insert(vertex_bind_desc.binding);
1828
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001829 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001830 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1831 "vkCreateGraphicsPipelines: parameter "
1832 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1833 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1834 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001835 }
1836
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001837 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001838 skip |=
1839 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1840 "vkCreateGraphicsPipelines: parameter "
1841 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1842 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1843 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001844 }
1845 }
1846
Peter Kohautc7d9d392018-07-15 00:34:07 +02001847 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001848 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1849 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001850 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1851 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001852 skip |= LogError(
1853 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001854 "vkCreateGraphicsPipelines: parameter "
1855 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1856 i, d, vertex_attrib_desc.location);
1857 }
1858 attribute_locations.insert(vertex_attrib_desc.location);
1859
1860 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1861 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001862 skip |= LogError(
1863 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001864 "vkCreateGraphicsPipelines: parameter "
1865 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1866 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1867 i, d, vertex_attrib_desc.binding, i);
1868 }
1869
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001870 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1872 "vkCreateGraphicsPipelines: parameter "
1873 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1874 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1875 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001876 }
1877
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001878 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001879 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1880 "vkCreateGraphicsPipelines: parameter "
1881 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1882 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1883 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001884 }
1885
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001886 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001887 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1888 "vkCreateGraphicsPipelines: parameter "
1889 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1890 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1891 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001892 }
1893 }
1894 }
1895
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001896 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1897 if (has_control && has_eval) {
1898 if (pCreateInfos[i].pTessellationState == nullptr) {
1899 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1900 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1901 "shader stage and a tessellation evaluation shader stage, "
1902 "pCreateInfos[%d].pTessellationState must not be NULL.",
1903 i, i);
1904 } else {
1905 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1906 skip |= validate_struct_pnext(
1907 "vkCreateGraphicsPipelines",
1908 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1909 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1910 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1911 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001912
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001913 skip |= validate_reserved_flags(
1914 "vkCreateGraphicsPipelines",
1915 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1916 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001917
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001918 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1919 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1920 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1921 "vkCreateGraphicsPipelines: invalid parameter "
1922 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1923 "should be >0 and <=%u.",
1924 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1925 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001926 }
1927 }
1928 }
1929
1930 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1931 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1932 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1933 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001934 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1935 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1936 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1937 "].pViewportState (=NULL) is not a valid pointer.",
1938 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001939 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001940 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1941
1942 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001943 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1944 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1945 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1946 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001947 }
1948
Petr Krausa6103552017-11-16 21:21:58 +01001949 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1950 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001951 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1952 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001953 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1954 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001955 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001956 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001957 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001958 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001959 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001960 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1961 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001962 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001963 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1964 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001965
1966 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001967 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001969 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001970
Dave Houlton142c4cb2018-10-17 15:04:41 -06001971 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1972 pCreateInfos[i].pViewportState->pNext);
1973 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1974 pCreateInfos[i].pViewportState->pNext);
1975 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1976 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001977 const auto vp_swizzle_struct =
1978 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001979 const auto vp_w_scaling_struct =
1980 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001981
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001982 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001983 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001984 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1985 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1986 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1987 ") is not 1.",
1988 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001989 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001990
Petr Krausa6103552017-11-16 21:21:58 +01001991 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001992 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1993 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1994 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1995 ") is not 1.",
1996 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001997 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001998
Dave Houlton142c4cb2018-10-17 15:04:41 -06001999 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2000 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002001 skip |= LogError(
2002 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2003 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2004 "disabled, but pCreateInfos[%" PRIu32
2005 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2006 ") is not 1.",
2007 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002008 }
2009
Jeff Bolz9af91c52018-09-01 21:53:57 -05002010 if (shading_rate_image_struct &&
2011 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002012 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2013 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2014 "disabled, but pCreateInfos[%" PRIu32
2015 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2016 ") is neither 0 nor 1.",
2017 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002018 }
2019
Petr Krausa6103552017-11-16 21:21:58 +01002020 } else { // multiViewport enabled
2021 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002022 if (!has_dynamic_viewport_with_count) {
2023 skip |= LogError(
2024 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2025 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2026 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002027 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002028 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2029 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2030 "].pViewportState->viewportCount (=%" PRIu32
2031 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2032 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002033 } else if (has_dynamic_viewport_with_count) {
2034 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2035 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2036 "].pViewportState->viewportCount (=%" PRIu32
2037 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2038 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002039 }
Petr Krausa6103552017-11-16 21:21:58 +01002040
2041 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002042 if (!has_dynamic_scissor_with_count) {
2043 skip |= LogError(
2044 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2045 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2046 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002047 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002048 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2049 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2050 "].pViewportState->scissorCount (=%" PRIu32
2051 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2052 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002053 } else if (has_dynamic_scissor_with_count) {
2054 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2055 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2056 "].pViewportState->scissorCount (=%" PRIu32
2057 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2058 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002059 }
2060 }
2061
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002062 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002063 skip |=
2064 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2065 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2066 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2067 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002068 }
2069
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002070 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002071 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2072 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2073 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2074 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2075 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002076 }
2077
Piers Daniell39842ee2020-07-10 16:42:33 -06002078 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2079 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002080 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2081 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2082 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2083 "].pViewportState->viewportCount (=%" PRIu32 ").",
2084 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002085 }
2086
Dave Houlton142c4cb2018-10-17 15:04:41 -06002087 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002088 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002089 skip |=
2090 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2091 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2092 ") must be zero or identical to pCreateInfos[%" PRIu32
2093 "].pViewportState->viewportCount (=%" PRIu32 ").",
2094 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002095 }
2096
Dave Houlton142c4cb2018-10-17 15:04:41 -06002097 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002098 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002099 skip |= LogError(
2100 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002101 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2102 "] "
2103 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2104 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2105 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002106 }
2107
Petr Krausa6103552017-11-16 21:21:58 +01002108 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002109 skip |= LogError(
2110 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002111 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2112 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002113 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2114 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002115 }
2116
2117 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002118 skip |= LogError(
2119 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002120 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2121 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002122 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2123 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002124 }
2125
Jeff Bolz3e71f782018-08-29 23:15:45 -05002126 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002127 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2128 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2129 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002130 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002131 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2132 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2133 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2134 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002135 }
2136
Jeff Bolz9af91c52018-09-01 21:53:57 -05002137 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002138 shading_rate_image_struct->viewportCount > 0 &&
2139 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002140 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002141 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002142 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002143 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2144 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002145 i, i);
2146 }
2147
Chris Mayer328d8212018-12-11 14:16:18 +01002148 if (vp_swizzle_struct) {
2149 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002150 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2151 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2152 " does "
2153 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2154 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002155 }
2156 }
2157
Petr Krausb3fcdb42018-01-09 22:09:09 +01002158 // validate the VkViewports
2159 if (!has_dynamic_viewport && viewport_state.pViewports) {
2160 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2161 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002162 const char *fn_name = "vkCreateGraphicsPipelines";
2163 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2164 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2165 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002166 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002167 }
2168 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002169
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002170 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002171 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2172 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2173 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2174 "VK_NV_clip_space_w_scaling extension is not enabled.",
2175 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002176 }
2177
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002178 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002179 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2180 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2181 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2182 "VK_EXT_discard_rectangles extension is not enabled.",
2183 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002184 }
2185
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002186 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002187 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2188 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2189 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2190 "VK_EXT_sample_locations extension is not enabled.",
2191 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002192 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002193
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002194 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002195 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2196 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2197 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2198 "VK_NV_scissor_exclusive extension is not enabled.",
2199 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002200 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002201
2202 if (coarse_sample_order_struct &&
2203 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2204 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002205 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2206 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2207 "] "
2208 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2209 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2210 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002211 }
2212
2213 if (coarse_sample_order_struct) {
2214 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002216 }
2217 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002218
2219 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2220 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002221 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2222 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2223 "] "
2224 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2225 ") "
2226 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2227 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002228 }
2229 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002230 skip |= LogError(
2231 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002232 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2233 "] "
2234 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2235 i);
2236 }
2237 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002238 }
2239
2240 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002241 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2242 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2243 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2244 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002246 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002247 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002248 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2249 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002250 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002251 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002252 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002254 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002255 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002256 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002257 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2258 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259
2260 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002261 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002262 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002263 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002264
2265 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002266 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002267 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2268 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2269
2270 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002271 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002272 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2273 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002274 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002275 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002276
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002277 skip |= validate_flags(
2278 "vkCreateGraphicsPipelines",
2279 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2280 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002281 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002282
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002284 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2286 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2287
2288 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002289 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2291 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2292
2293 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002294 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2295 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2296 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2297 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298 }
John Zulauf7acac592017-11-06 11:15:53 -07002299 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002300 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2302 "vkCreateGraphicsPipelines(): parameter "
2303 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2304 i);
John Zulauf7acac592017-11-06 11:15:53 -07002305 }
2306 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2307 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2308 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002309 skip |= LogError(
2310 device,
2311
Dave Houlton413a6782018-05-22 13:01:54 -06002312 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002313 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002314 }
2315 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002316
2317 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2318 pCreateInfos[i].pRasterizationState->pNext);
2319
2320 if (line_state) {
2321 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2322 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2323 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2324 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002325 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2326 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2327 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2328 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002329 }
2330 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2331 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002332 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2333 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2334 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2335 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002336 }
2337 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2338 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002339 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2340 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2341 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2342 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002343 }
2344 }
2345 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2346 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2347 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002348 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2349 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2350 "range [1,256].",
2351 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002352 }
2353 }
2354 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002355 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002356 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2357 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |=
2359 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2360 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2361 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2362 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002363 }
2364 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2365 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002366 skip |=
2367 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2368 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2369 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2370 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002371 }
2372 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2373 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |=
2375 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2376 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2377 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2378 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002379 }
2380 if (line_state->stippledLineEnable) {
2381 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2382 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 skip |=
2384 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2385 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2386 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2387 "stippledRectangularLines feature.",
2388 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002389 }
2390 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2391 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002392 skip |=
2393 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2394 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2395 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2396 "stippledBresenhamLines feature.",
2397 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002398 }
2399 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2400 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002401 skip |=
2402 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2403 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2404 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2405 "stippledSmoothLines feature.",
2406 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002407 }
2408 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2409 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002410 skip |=
2411 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2412 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2413 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2414 "stippledRectangularLines and strictLines features.",
2415 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002416 }
2417 }
2418 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002419 }
2420
Petr Krause91f7a12017-12-14 20:57:36 +01002421 bool uses_color_attachment = false;
2422 bool uses_depthstencil_attachment = false;
2423 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002424 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002425 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2426 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002427 const auto &subpasses_uses = subpasses_uses_it->second;
2428 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2429 uses_color_attachment = true;
2430 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2431 uses_depthstencil_attachment = true;
2432 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002433 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002434 }
2435
2436 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002437 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002438 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002439 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002441 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002442
2443 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002444 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002446 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002447
2448 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002449 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2451 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2452
2453 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002454 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002455 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2456 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2457
2458 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002459 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002460 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2461 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002462 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002463
2464 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002465 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2467 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2468
2469 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002470 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002471 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2472 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2473
2474 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002475 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2477 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002478 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002479
2480 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002481 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002482 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2483 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002484 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485
2486 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002487 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2489 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002490 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491
2492 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002493 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2495 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002496 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497
2498 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2501 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002502 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002503
2504 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002505 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2507 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002508 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509
2510 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002512 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2513 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002514 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515
2516 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002517 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2519 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002520 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002521
2522 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002523 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2524 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2525 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2526 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002527 }
2528 }
2529
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002530 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2531 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2532
Petr Krause91f7a12017-12-14 20:57:36 +01002533 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002534 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2535 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2536 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2537 pCreateInfos[i].pColorBlendState,
2538 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2539 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2540
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002541 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002542 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002543 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2544 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2545 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002546 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002547 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2548 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549
2550 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002551 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002552 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002553 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554
2555 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002556 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002557 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2558 pCreateInfos[i].pColorBlendState->logicOpEnable);
2559
2560 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002561 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002562 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2563 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002564 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002565 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566
2567 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2568 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2569 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002570 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002571 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2572 ParameterName::IndexVector{i, attachmentIndex}),
2573 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2574
2575 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002576 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002577 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2578 ParameterName::IndexVector{i, attachmentIndex}),
2579 "VkBlendFactor", AllVkBlendFactorEnums,
2580 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002581 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002582
2583 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002584 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002585 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2586 ParameterName::IndexVector{i, attachmentIndex}),
2587 "VkBlendFactor", AllVkBlendFactorEnums,
2588 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002589 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590
2591 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002592 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2594 ParameterName::IndexVector{i, attachmentIndex}),
2595 "VkBlendOp", AllVkBlendOpEnums,
2596 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002597 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002598
2599 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002600 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002601 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2602 ParameterName::IndexVector{i, attachmentIndex}),
2603 "VkBlendFactor", AllVkBlendFactorEnums,
2604 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002605 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002606
2607 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002608 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002609 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2610 ParameterName::IndexVector{i, attachmentIndex}),
2611 "VkBlendFactor", AllVkBlendFactorEnums,
2612 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002613 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002614
2615 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002616 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2618 ParameterName::IndexVector{i, attachmentIndex}),
2619 "VkBlendOp", AllVkBlendOpEnums,
2620 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002621 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002622
2623 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002624 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002625 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2626 ParameterName::IndexVector{i, attachmentIndex}),
2627 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2628 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002629 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002630 }
2631 }
2632
2633 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002634 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2635 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2636 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2637 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002638 }
2639
2640 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2641 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2642 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002643 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002645 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2646 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 }
2648 }
2649 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650
Petr Kraus9752aae2017-11-24 03:05:50 +01002651 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2652 if (pCreateInfos[i].basePipelineIndex != -1) {
2653 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002654 skip |=
2655 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002656 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002657 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002658 "and pCreateInfos->basePipelineIndex is not -1.",
2659 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002660 }
2661 }
2662
Petr Kraus9752aae2017-11-24 03:05:50 +01002663 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2664 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002665 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002666 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002667 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002668 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2669 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002670 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002671 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002672 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002673 skip |=
2674 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2675 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2676 "index into the pCreateInfos array, of size %d.",
2677 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002678 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002679 }
2680 }
2681
sfricke-samsung898cf222020-05-15 23:10:19 -07002682 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2683 skip |= LogError(
2684 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2685 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2686 i);
2687 }
2688
Petr Kraus9752aae2017-11-24 03:05:50 +01002689 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002690 if (!device_extensions.vk_nv_fill_rectangle) {
2691 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2692 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002693 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2694 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2695 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2696 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002697 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2698 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002699 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2700 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002701 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2702 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2703 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002704 }
2705 } else {
2706 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2707 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2708 (physical_device_features.fillModeNonSolid == false)) {
2709 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2711 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002712 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2713 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2714 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002715 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002716 }
Petr Kraus299ba622017-11-24 03:09:03 +01002717
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002718 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002719 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002720 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2721 "The line width state is static (pCreateInfos[%" PRIu32
2722 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2723 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2724 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2725 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002726 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002728 }
2729 }
2730
2731 return skip;
2732}
2733
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002734bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2735 uint32_t createInfoCount,
2736 const VkComputePipelineCreateInfo *pCreateInfos,
2737 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002738 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002739 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002740 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002741 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002743 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002744 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2745 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002746 skip |=
2747 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2748 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2749 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2750 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002751 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002752
2753 // Make sure compute stage is selected
2754 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002755 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2756 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2757 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002758 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002759 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 return skip;
2761}
2762
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002763bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002764 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766
2767 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002768 const auto &features = physical_device_features;
2769 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002770
John Zulauf71968502017-10-26 13:51:15 -06002771 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2772 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002773 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2774 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2775 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2776 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002777 }
2778
2779 // Anistropy cannot be enabled in sampler unless enabled as a feature
2780 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002781 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2782 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2783 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002784 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002785 }
John Zulauf71968502017-10-26 13:51:15 -06002786
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002787 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2788 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002789 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2790 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2791 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2792 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002793 }
2794 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002795 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2796 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2797 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2798 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002799 }
2800 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2802 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2803 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2804 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002805 }
2806 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2807 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2808 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2809 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002810 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2811 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2812 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2813 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2814 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2815 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002816 }
2817 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002818 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2819 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2820 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002821 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002822 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002823 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2824 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2825 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002826 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002827 }
2828
2829 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2830 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002831 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2832 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002833 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2834 if (sampler_reduction != nullptr) {
2835 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2836 skip |= LogError(
2837 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2838 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2839 }
2840 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 }
2842
2843 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2844 // valid VkBorderColor value
2845 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2846 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2847 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002848 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2849 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002850 }
2851
2852 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2853 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002854 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2856 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2857 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002858 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002859 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2860 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2861 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 }
John Zulauf275805c2017-10-26 15:34:49 -06002863
2864 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002865 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002866 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2867 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002868 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2869 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2870 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002871 }
2872 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002873
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002874 // Check for valid Lod range
2875 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002876 skip |=
2877 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2878 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002879 }
2880
2881 // Check mipLodBias to device limit
2882 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002883 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2884 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2885 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002886 }
2887
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002888 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2889 if (sampler_conversion != nullptr) {
2890 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2891 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2892 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2893 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002894 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002895 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002896 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2897 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2898 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2899 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2900 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2901 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2902 }
2903 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002904
2905 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2906 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2907 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2908 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2909 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2910 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2911 }
2912 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2913 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2914 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2915 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2916 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2917 }
2918 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2919 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2920 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2921 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2922 pCreateInfo->minLod, pCreateInfo->maxLod);
2923 }
2924 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2925 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2926 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2927 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2928 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2929 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2930 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2931 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2932 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2933 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2934 }
2935 if (pCreateInfo->anisotropyEnable) {
2936 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2937 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2938 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2939 }
2940 if (pCreateInfo->compareEnable) {
2941 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2942 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2943 "pCreateInfo->compareEnable must be VK_FALSE");
2944 }
2945 if (pCreateInfo->unnormalizedCoordinates) {
2946 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2947 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2948 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2949 }
2950 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002951 }
2952
Tony-LunarG7337b312020-04-15 16:40:25 -06002953 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2954 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2955 if (!device_extensions.vk_ext_custom_border_color) {
2956 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2957 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2958 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2959 }
2960 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2961 if (!custom_create_info) {
2962 skip |=
2963 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2964 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2965 "struct in pNext chain.\n",
2966 string_VkBorderColor(pCreateInfo->borderColor));
2967 } else {
2968 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2969 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2970 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2971 !FormatIsSampledFloat(custom_create_info->format)))) {
2972 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2973 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2974 "whose type does not match\n",
2975 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2976 ;
2977 }
2978 }
2979 }
2980
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002981 return skip;
2982}
2983
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002984bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2985 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2986 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002987 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002988 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989
2990 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2991 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2992 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2993 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2995 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2996 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2997 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2998 ++descriptor_index) {
2999 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003000 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003001 "vkCreateDescriptorSetLayout: required parameter "
3002 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3003 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003004 }
3005 }
3006 }
3007
3008 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3009 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3010 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003011 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3012 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3013 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3014 "values.",
3015 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003016 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003017
3018 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3019 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3020 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3021 skip |=
3022 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3023 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3024 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3025 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3026 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3027 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028 }
3029 }
3030 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003031 return skip;
3032}
3033
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003034bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3035 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003036 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3038 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3039 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003040 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3041 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003042}
3043
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003044bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3045 const VkWriteDescriptorSet *pDescriptorWrites,
3046 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003048
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003049 if (pDescriptorWrites != NULL) {
3050 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3051 // descriptorCount must be greater than 0
3052 if (pDescriptorWrites[i].descriptorCount == 0) {
3053 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003054 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3055 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003056 }
3057
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003058 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3059 if (validateDstSet) {
3060 // dstSet must be a valid VkDescriptorSet handle
3061 skip |= validate_required_handle(vkCallingFunction,
3062 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3063 pDescriptorWrites[i].dstSet);
3064 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065
3066 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3067 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3068 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3069 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3070 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3071 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3072 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003073 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3074 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003075 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003076 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3077 "%s(): if pDescriptorWrites[%d].descriptorType is "
3078 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3079 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3080 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3081 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003082 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3083 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003084 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3085 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003086 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3087 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003088 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003089 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3090 ParameterName::IndexVector{i, descriptor_index}),
3091 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003092 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003093 }
3094 }
3095 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3096 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3097 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3098 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3099 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3100 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3101 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003102 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003103 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003104 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3105 "%s(): if pDescriptorWrites[%d].descriptorType is "
3106 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3107 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3108 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3109 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003111 const auto *robustness2_features =
3112 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3113 if (robustness2_features && robustness2_features->nullDescriptor) {
3114 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
3115 ++descriptorIndex) {
3116 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
3117 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
3118 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
3119 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3120 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
3121 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
3122 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
3123 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
3124 }
3125 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003126 }
3127 }
3128 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3129 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003130 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003131 }
3132
3133 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3134 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003135 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3137 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3138 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003139 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003140 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3141 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3142 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3143 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 }
3145 }
3146 }
3147 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3148 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003149 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3151 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3152 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003153 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003154 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3155 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3156 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3157 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 }
3159 }
3160 }
3161 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003162 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3163 // or VkWriteDescriptorSetInlineUniformBlockEX
3164 if (pDescriptorWrites[i].pNext) {
3165 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003166 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003167 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003168 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003169 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3170 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3171 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3172 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003173 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003174 pDescriptorWrites[i].descriptorCount);
3175 }
3176 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003177 if (pnext_struct) {
3178 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003179 skip |= LogError(
3180 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3181 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3182 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003183 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003184 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003185 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003186 skip |= LogError(
3187 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3188 "%s(): accelerationStructureCount must be greater than 0 .");
3189 }
3190 }
3191 }
3192 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003193 }
3194 }
3195 return skip;
3196}
3197
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003198bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3199 const VkWriteDescriptorSet *pDescriptorWrites,
3200 uint32_t descriptorCopyCount,
3201 const VkCopyDescriptorSet *pDescriptorCopies) const {
3202 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3203}
3204
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003205bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003206 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003207 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003208 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3209}
3210
3211bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003212 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003213 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003214 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3215}
3216
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003217bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3218 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003219 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003220 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221
3222 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3223 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3224 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003225 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3226 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003227 return skip;
3228}
3229
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003230bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003231 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003233
3234 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3235 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003236 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3237
Petr Krause7bb9e82019-08-11 21:34:43 +02003238 // Implicit VUs
3239 // validate only sType here; pointer has to be validated in core_validation
3240 const bool kNotRequired = false;
3241 const char *kNoVUID = nullptr;
3242 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3243 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3244 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245
Petr Krause7bb9e82019-08-11 21:34:43 +02003246 if (pInfo) {
3247 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3248 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3249 skip |= validate_struct_pnext(
3250 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3251 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003252 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3253 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003254
Petr Krause7bb9e82019-08-11 21:34:43 +02003255 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003256
Petr Krause7bb9e82019-08-11 21:34:43 +02003257 // Explicit VUs
3258 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003259 skip |= LogError(
3260 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003261 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3262 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003264
3265 if (physical_device_features.inheritedQueries) {
3266 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003267 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003268 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003269 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003270 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003271 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003272 }
3273
3274 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003275 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003276 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003277 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003278 } else { // !pipelineStatisticsQuery
3279 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3280 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003281 }
Petr Kraus139757b2019-08-15 17:19:33 +02003282
3283 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3284 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003285 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003286 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3287 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003288 skip |= LogError(
3289 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003290 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3291 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3292 }
3293 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003294 }
3295
3296 return skip;
3297}
3298
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003299bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003300 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003301 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003303 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003304 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003305 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3306 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3307 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003308 }
3309 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003310 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3311 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3312 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003313 }
3314 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003315 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003316 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3318 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3319 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3320 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003321 }
3322 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003323
3324 if (pViewports) {
3325 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3326 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003327 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003328 skip |= manual_PreCallValidateViewport(
3329 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003330 }
3331 }
3332
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 return skip;
3334}
3335
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003336bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003337 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003338 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003339
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003340 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003341 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003342 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3343 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3344 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003345 }
3346 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003347 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3348 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3349 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003350 }
3351 } else { // multiViewport enabled
3352 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003353 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003354 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3355 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3356 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3357 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003358 }
3359 }
3360
Petr Kraus6260f0a2018-02-27 21:15:55 +01003361 if (pScissors) {
3362 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3363 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003364
Petr Kraus6260f0a2018-02-27 21:15:55 +01003365 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3367 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3368 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003369 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003370
Petr Kraus6260f0a2018-02-27 21:15:55 +01003371 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003372 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3373 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3374 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003375 }
3376
3377 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3378 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003379 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3380 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3381 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3382 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003383 }
3384
3385 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3386 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003387 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3388 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3389 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3390 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003391 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003392 }
3393 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003394
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 return skip;
3396}
3397
Jeff Bolz5c801d12019-10-09 10:38:45 -05003398bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003399 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003400
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003401 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003402 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3403 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003404 }
3405
3406 return skip;
3407}
3408
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003409bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003410 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412 if (vertexCount == 0) {
3413 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3414 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003415 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003416 }
3417
3418 if (instanceCount == 0) {
3419 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3420 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003421 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003422 }
3423 return skip;
3424}
3425
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003426bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003427 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003429
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003430 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003431 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3432 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 }
3434 return skip;
3435}
3436
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003437bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003438 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003440 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003441 skip |=
3442 LogError(device, kVUID_PVError_DeviceFeature,
3443 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444 }
3445 return skip;
3446}
3447
sfricke-samsungf692b972020-05-02 08:00:45 -07003448bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3449 VkDeviceSize countBufferOffset, bool khr) const {
3450 bool skip = false;
3451 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3452 if (offset & 3) {
3453 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3454 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3455 }
3456
3457 if (countBufferOffset & 3) {
3458 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3459 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3460 countBufferOffset);
3461 }
3462 return skip;
3463}
3464
3465bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3466 VkDeviceSize offset, VkBuffer countBuffer,
3467 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3468 uint32_t stride) const {
3469 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3470}
3471
3472bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3473 VkDeviceSize offset, VkBuffer countBuffer,
3474 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3475 uint32_t stride) const {
3476 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3477}
3478
3479bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3480 VkDeviceSize countBufferOffset, bool khr) const {
3481 bool skip = false;
3482 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3483 if (offset & 3) {
3484 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3485 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3486 }
3487
3488 if (countBufferOffset & 3) {
3489 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3490 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3491 countBufferOffset);
3492 }
3493 return skip;
3494}
3495
3496bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3497 VkDeviceSize offset, VkBuffer countBuffer,
3498 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3499 uint32_t stride) const {
3500 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3501}
3502
3503bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3504 VkDeviceSize offset, VkBuffer countBuffer,
3505 VkDeviceSize countBufferOffset,
3506 uint32_t maxDrawCount, uint32_t stride) const {
3507 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3508}
3509
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003510bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3511 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003512 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003513 bool skip = false;
3514 for (uint32_t rect = 0; rect < rectCount; rect++) {
3515 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003516 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3517 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003518 }
sfricke-samsung10867682020-04-25 02:20:39 -07003519 if (pRects[rect].rect.extent.width == 0) {
3520 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3521 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3522 }
3523 if (pRects[rect].rect.extent.height == 0) {
3524 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3525 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3526 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003527 }
3528 return skip;
3529}
3530
Andrew Fobel3abeb992020-01-20 16:33:22 -05003531bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3532 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3533 VkImageFormatProperties2 *pImageFormatProperties,
3534 const char *apiName) const {
3535 bool skip = false;
3536
3537 if (pImageFormatInfo != nullptr) {
3538 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3539 if (image_stencil_struct != nullptr) {
3540 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3541 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3542 // No flags other than the legal attachment bits may be set
3543 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3544 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003545 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3546 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3547 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3548 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3549 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003550 }
3551 }
3552 }
3553 }
3554
3555 return skip;
3556}
3557
3558bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3559 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3560 VkImageFormatProperties2 *pImageFormatProperties) const {
3561 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3562 "vkGetPhysicalDeviceImageFormatProperties2");
3563}
3564
3565bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3566 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3567 VkImageFormatProperties2 *pImageFormatProperties) const {
3568 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3569 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3570}
3571
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003572bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3573 VkImageLayout srcImageLayout, VkImage dstImage,
3574 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003575 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003576 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003577
Dave Houltonf5217612018-02-02 16:18:52 -07003578 VkImageAspectFlags legal_aspect_flags =
3579 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 -07003580 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003581 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3582 }
3583
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003584 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003585 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 skip |= LogError(
3587 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003588 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003589 }
Dave Houltonf5217612018-02-02 16:18:52 -07003590 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003591 skip |= LogError(
3592 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003593 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594 }
3595 }
3596 return skip;
3597}
3598
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003599bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3600 VkImageLayout srcImageLayout, VkImage dstImage,
3601 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003602 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003603 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003604
Dave Houltonf5217612018-02-02 16:18:52 -07003605 VkImageAspectFlags legal_aspect_flags =
3606 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 -07003607 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003608 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3609 }
3610
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003612 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003613 skip |= LogError(
3614 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003615 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3616 }
Dave Houltonf5217612018-02-02 16:18:52 -07003617 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 skip |= LogError(
3619 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003620 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3621 }
3622 }
3623 return skip;
3624}
3625
sfricke-samsung3999ef62020-02-09 17:05:59 -08003626bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3627 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3628 bool skip = false;
3629
3630 if (pRegions != nullptr) {
3631 for (uint32_t i = 0; i < regionCount; i++) {
3632 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003633 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3634 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003635 }
3636 }
3637 }
3638 return skip;
3639}
3640
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003641bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3642 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003643 uint32_t regionCount,
3644 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003645 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003646
Dave Houltonf5217612018-02-02 16:18:52 -07003647 VkImageAspectFlags legal_aspect_flags =
3648 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 -07003649 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003650 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3651 }
3652
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003653 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003654 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003655 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3656 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3657 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003658 }
3659 }
3660 return skip;
3661}
3662
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003663bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3664 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003665 uint32_t regionCount,
3666 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003667 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003668
Dave Houltonf5217612018-02-02 16:18:52 -07003669 VkImageAspectFlags legal_aspect_flags =
3670 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 -07003671 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003672 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3673 }
3674
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003675 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003676 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003677 skip |= LogError(
3678 device, kVUID_PVError_UnrecognizedValue,
3679 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3680 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003681 }
3682 }
3683 return skip;
3684}
3685
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003686bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003687 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3688 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003689 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003690
3691 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003692 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3693 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3694 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003695 }
3696
3697 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003698 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3699 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3700 "), must be greater than zero and less than or equal to 65536.",
3701 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003702 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003703 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3704 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3705 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003706 }
3707 return skip;
3708}
3709
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003710bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003711 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003712 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003713
3714 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003715 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3716 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3717 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718 }
3719
3720 if (size != VK_WHOLE_SIZE) {
3721 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003722 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003723 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3724 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003725 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3727 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003728 }
3729 }
3730 return skip;
3731}
3732
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003733bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003734 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003735 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003736 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003737
3738 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003739 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3740 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3741 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3742 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003743 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3744 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3745 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003746 }
3747
3748 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3749 // queueFamilyIndexCount uint32_t values
3750 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003751 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3752 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3753 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3754 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003755 }
3756 }
3757
Dave Houlton413a6782018-05-22 13:01:54 -06003758 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003759 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003760 }
3761
3762 return skip;
3763}
3764
Jeff Bolz5c801d12019-10-09 10:38:45 -05003765bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003766 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003767
3768 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003769 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3770 if (present_regions) {
3771 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003772 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003773 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3774 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003775 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003776 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3777 "extension swapchainCount is %i. These values must be equal.",
3778 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003779 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003780 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003781 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3782 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003783 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3784 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3785 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003786 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003787 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003788 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003789 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003790 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003791 }
3792 }
3793
3794 return skip;
3795}
3796
3797#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003798bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3799 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3800 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003801 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003802 bool skip = false;
3803
3804 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003805 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3806 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003807 }
3808
3809 return skip;
3810}
3811#endif // VK_USE_PLATFORM_WIN32_KHR
3812
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003813bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003814 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003815 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003816 bool skip = false;
3817
3818 if (pCreateInfo) {
3819 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3821 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003822 }
3823
3824 if (pCreateInfo->pPoolSizes) {
3825 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3826 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003827 skip |= LogError(
3828 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003829 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003830 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003831 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3832 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003833 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3834 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3835 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3836 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3837 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003838 }
Petr Krausc8655be2017-09-27 18:56:51 +02003839 }
3840 }
3841 }
3842
3843 return skip;
3844}
3845
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003846bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003847 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003848 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003849
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003850 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003851 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003852 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3853 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3854 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003855 }
3856
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003857 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003858 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003859 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3860 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3861 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003862 }
3863
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003864 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003865 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003866 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3867 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3868 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003869 }
3870
3871 return skip;
3872}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003873
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003874bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003875 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003876 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003877
3878 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003879 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3880 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003881 }
3882 return skip;
3883}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003884
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003885bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3886 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003887 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003888 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003889
3890 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003891 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003892 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003893 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3894 "vkCmdDispatch(): baseGroupX (%" PRIu32
3895 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3896 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003897 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003898 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3899 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3900 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3901 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003902 }
3903
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003904 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003905 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003906 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3907 "vkCmdDispatch(): baseGroupY (%" PRIu32
3908 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3909 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003910 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003911 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3912 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3913 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3914 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003915 }
3916
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003917 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003918 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3920 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3921 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3922 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003923 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003924 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3925 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3926 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3927 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003928 }
3929
3930 return skip;
3931}
3932
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003933bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3934 VkPipelineBindPoint pipelineBindPoint,
3935 VkPipelineLayout layout, uint32_t set,
3936 uint32_t descriptorWriteCount,
3937 const VkWriteDescriptorSet *pDescriptorWrites) const {
3938 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3939}
3940
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003941bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3942 uint32_t firstExclusiveScissor,
3943 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003944 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003945 bool skip = false;
3946
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003947 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003948 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003949 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003950 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3951 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3952 ") is not 0.",
3953 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003954 }
3955 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003956 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003957 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3958 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3959 ") is not 1.",
3960 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003961 }
3962 } else { // multiViewport enabled
3963 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003964 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003965 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3966 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3967 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3968 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003969 }
3970 }
3971
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003972 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003973 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3974 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3975 ") must be less than maxViewports (=%" PRIu32 ").",
3976 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003977 }
3978
3979 if (pExclusiveScissors) {
3980 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3981 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3982
3983 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003984 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3985 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3986 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003987 }
3988
3989 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003990 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3991 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3992 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003993 }
3994
3995 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3996 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003997 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3998 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3999 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4000 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004001 }
4002
4003 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
4004 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004005 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
4006 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
4007 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
4008 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05004009 }
4010 }
4011 }
4012
4013 return skip;
4014}
4015
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004016bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
4017 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004018 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004019 bool skip = false;
4020 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004021 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
4022 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
4023 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004024 } else {
4025 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
4026 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004027 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
4028 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
4029 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
4030 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02004031 }
4032 }
4033
4034 return skip;
4035}
4036
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004037bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
4038 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004039 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004040 bool skip = false;
4041
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004042 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004043 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004044 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004045 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
4046 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
4047 ") is not 0.",
4048 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004049 }
4050 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06004051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004052 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
4053 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
4054 ") is not 1.",
4055 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004056 }
4057 }
4058
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004059 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
4061 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
4062 ") must be less than maxViewports (=%" PRIu32 ").",
4063 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004064 }
4065
4066 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004067 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004068 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
4069 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
4070 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
4071 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004072 }
4073
4074 return skip;
4075}
4076
Jeff Bolz5c801d12019-10-09 10:38:45 -05004077bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
4078 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
4079 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05004080 bool skip = false;
4081
Dave Houlton142c4cb2018-10-17 15:04:41 -06004082 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
4084 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
4085 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05004086 }
4087
4088 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004089 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05004090 }
4091
4092 return skip;
4093}
4094
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004095bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004096 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004097 bool skip = false;
4098
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004099 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004100 skip |= LogError(
4101 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004102 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
4103 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004104 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004105 }
4106
4107 return skip;
4108}
4109
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004110bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4111 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004112 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004113 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004114 static const int condition_multiples = 0b0011;
4115 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004116 skip |= LogError(
4117 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004118 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004119 }
Lockee1c22882019-06-10 16:02:54 -06004120 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004121 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4122 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4123 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4124 stride);
Lockee1c22882019-06-10 16:02:54 -06004125 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004126 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004127 skip |= LogError(
4128 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4129 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004130 }
4131
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004132 return skip;
4133}
4134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004135bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4136 VkDeviceSize offset, VkBuffer countBuffer,
4137 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004138 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004139 bool skip = false;
4140
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004141 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004142 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4143 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4144 "), is not a multiple of 4.",
4145 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004146 }
4147
4148 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004149 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4150 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4151 "), is not a multiple of 4.",
4152 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004153 }
4154
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004155 return skip;
4156}
4157
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004158bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004159 const VkAllocationCallbacks *pAllocator,
4160 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004161 bool skip = false;
4162
4163 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4164 if (pCreateInfo != nullptr) {
4165 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4166 // VkQueryPipelineStatisticFlagBits values
4167 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4168 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004169 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4170 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4171 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4172 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004173 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004174 if (pCreateInfo->queryCount == 0) {
4175 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4176 "vkCreateQueryPool(): queryCount must be greater than zero.");
4177 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004178 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004179 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004180}
4181
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004182bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4183 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004184 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004185 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4186 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004187}
4188
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004189void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004190 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4191 VkResult result) {
4192 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004193 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004194}
4195
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004196void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004197 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4198 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004199 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004200 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004201 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004202}
4203
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004204void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4205 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004206 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004207 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004208 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004209}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004210
4211bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004212 const VkAllocationCallbacks *pAllocator,
4213 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004214 bool skip = false;
4215
4216 if (pAllocateInfo) {
4217 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4218 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004219 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4220 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004221 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004222
4223 VkMemoryAllocateFlags flags = 0;
4224 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4225 if (flags_info) {
4226 flags = flags_info->flags;
4227 }
4228
4229 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4230 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4231 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004232 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4233 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4234 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004235 }
4236
4237#ifdef VK_USE_PLATFORM_WIN32_KHR
4238 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4239#endif
4240 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4241 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4242#ifdef VK_USE_PLATFORM_ANDROID_KHR
4243 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4244#endif
4245
4246 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004247 skip |= LogError(
4248 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004249 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4250 }
4251 if (
4252#ifdef VK_USE_PLATFORM_WIN32_KHR
4253 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4254#endif
4255 (import_memory_fd && import_memory_fd->handleType) ||
4256#ifdef VK_USE_PLATFORM_ANDROID_KHR
4257 (import_memory_ahb && import_memory_ahb->buffer) ||
4258#endif
4259 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004260 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4261 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004262 }
4263 }
4264
4265 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004266 VkBool32 capture_replay = false;
4267 VkBool32 buffer_device_address = false;
4268 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4269 if (vulkan_12_features) {
4270 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4271 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4272 } else {
4273 const auto *bda_features =
4274 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4275 if (bda_features) {
4276 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4277 buffer_device_address = bda_features->bufferDeviceAddress;
4278 }
4279 }
4280 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004281 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4282 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4283 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004284 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004285 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004286 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4287 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004288 }
4289 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004290 }
4291 return skip;
4292}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004293
Jason Macnak192fa0e2019-07-26 15:07:16 -07004294bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004295 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004296 bool skip = false;
4297
4298 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4299 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4300 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004301 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004302 } else {
4303 uint32_t vertex_component_size = 0;
4304 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4305 vertex_component_size = 4;
4306 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4307 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4308 vertex_component_size = 2;
4309 }
4310 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004311 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004312 }
4313 }
4314
4315 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4316 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004317 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004318 } else {
4319 uint32_t index_element_size = 0;
4320 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4321 index_element_size = 4;
4322 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4323 index_element_size = 2;
4324 }
4325 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004326 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004327 }
4328 }
4329 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4330 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004331 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004332 }
4333 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004334 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004335 }
4336 }
4337
4338 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004339 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004340 }
4341
4342 return skip;
4343}
4344
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004345bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4346 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004347 bool skip = false;
4348
4349 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004350 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004351 }
4352 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004353 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004354 }
4355
4356 return skip;
4357}
4358
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004359bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4360 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004361 bool skip = false;
4362 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004363 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004364 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004365 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004366 }
4367 return skip;
4368}
4369
4370bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004371 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004372 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004373 bool skip = false;
4374 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004375 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4376 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4377 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004378 }
4379 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004380 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4381 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4382 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004383 }
4384 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4385 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004386 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4387 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4388 "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 -07004389 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004390 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004391 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004392 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4393 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004394 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4395 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004396 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004397 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004398 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4399 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4400 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004401 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004402 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004403 uint64_t total_triangle_count = 0;
4404 for (uint32_t i = 0; i < info.geometryCount; i++) {
4405 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004406
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004407 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004408
Jason Macnak5c954952019-07-09 15:46:12 -07004409 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4410 continue;
4411 }
4412 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4413 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004414 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004415 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4416 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4417 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004418 }
4419 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004420 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4421 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4422 for (uint32_t i = 1; i < info.geometryCount; i++) {
4423 const VkGeometryNV &geometry = info.pGeometries[i];
4424 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004425 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004426 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4427 "info.pGeometries[0].geometryType.",
4428 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004429 }
4430 }
4431 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004432 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4433 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4434 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4435 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4436 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4437 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4438 }
4439 }
4440 skip |=
4441 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004442 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004443 return skip;
4444}
4445
Ricardo Garciaa4935972019-02-21 17:43:18 +01004446bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4447 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004448 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004449 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004450 if (pCreateInfo) {
4451 if ((pCreateInfo->compactedSize != 0) &&
4452 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004453 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4454 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4455 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4456 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004457 }
Jason Macnak5c954952019-07-09 15:46:12 -07004458
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004459 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004460 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004461 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004462 return skip;
4463}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004464
Jeff Bolz5c801d12019-10-09 10:38:45 -05004465bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4466 const VkAccelerationStructureInfoNV *pInfo,
4467 VkBuffer instanceData, VkDeviceSize instanceOffset,
4468 VkBool32 update, VkAccelerationStructureNV dst,
4469 VkAccelerationStructureNV src, VkBuffer scratch,
4470 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004471 bool skip = false;
4472
4473 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004474 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004475 }
4476
4477 return skip;
4478}
4479
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004480bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4481 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4482 VkAccelerationStructureKHR *pAccelerationStructure) const {
4483 bool skip = false;
4484
4485 if (pCreateInfo) {
4486 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4487 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4488 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4489 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4490 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4491 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4492 i);
4493 }
4494 }
4495
4496 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4497 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4498 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4499 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4500 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4501 i);
4502 }
4503 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004504 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4505 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4506 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4507 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4508 skip |= LogError(
4509 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4510 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4511 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4512 }
4513 }
4514 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4515 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4516 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4517 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4518 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4519 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4520 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4521 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4522 }
4523 }
4524 }
4525
4526 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4527 pCreateInfo->maxGeometryCount != 1) {
4528 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4529 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4530 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004531 }
sourav parmard1521802020-06-07 21:49:02 -07004532 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4533 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4534 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4535 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4536 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004537
4538 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4539 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4540 skip |= LogError(
4541 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4542 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4543 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4544 }
4545
4546 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4547 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4548 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4549 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4550 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4551 }
4552
4553 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4554 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4555 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4556 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4557 if (geometry_type != first_geometry_type) {
4558 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4559 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4560 "pGeometryInfos[0].geometryType.",
4561 i);
4562 }
4563 }
4564 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004565 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4566 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4567 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4568 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4569 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4570 "maxGeometryCount %d.",
4571 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4572 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004573 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004574 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4575 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4576 if (pCreateInfo->deviceAddress != 0) {
4577 skip |=
4578 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4579 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4580 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4581 }
4582 }
sourav parmar83c31b12020-05-06 12:30:54 -07004583 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4584 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4585 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4586 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004587 return skip;
4588}
4589
Jason Macnak5c954952019-07-09 15:46:12 -07004590bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4591 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004592 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004593 bool skip = false;
4594 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004595 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4596 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004597 }
4598 return skip;
4599}
4600
Peter Chen85366392019-05-14 15:20:11 -04004601bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4602 uint32_t createInfoCount,
4603 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4604 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004605 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004606 bool skip = false;
4607
4608 for (uint32_t i = 0; i < createInfoCount; i++) {
4609 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4610 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004611 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004612 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4613 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4614 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4615 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004616 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004617
4618 const auto *pipeline_cache_contol_features =
4619 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4620 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4621 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4622 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4623 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4624 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4625 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4626 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4627 }
4628 }
4629
sourav parmarf4a78252020-04-10 13:04:21 -07004630 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4631 skip |=
4632 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4633 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4634 }
4635 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4636 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4637 skip |=
4638 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4639 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4640 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4641 }
4642 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4643 if (pCreateInfos[i].basePipelineIndex != -1) {
4644 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4645 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4646 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4647 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4648 "and pCreateInfos->basePipelineIndex is not -1.");
4649 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004650 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4651 skip |=
4652 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4653 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4654 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4655 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4656 "that element.");
4657 }
sourav parmarf4a78252020-04-10 13:04:21 -07004658 }
4659 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004660 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004661 skip |=
4662 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4663 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4664 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4665 "commands pCreateInfos parameter.");
4666 }
4667 } else {
4668 if (pCreateInfos[i].basePipelineIndex != -1) {
4669 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4670 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4671 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4672 }
4673 }
4674 }
4675 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4676 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4677 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4678 }
4679 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4680 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4681 "vkCreateRayTracingPipelinesNV: flags must not include "
4682 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4683 }
4684 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4685 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4686 "vkCreateRayTracingPipelinesNV: flags must not include "
4687 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4688 }
4689 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4690 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4691 "vkCreateRayTracingPipelinesNV: flags must not include "
4692 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4693 }
4694 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4695 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4696 "vkCreateRayTracingPipelinesNV: flags must not include "
4697 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4698 }
4699 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4700 skip |= LogError(
4701 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4702 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4703 }
4704 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4705 skip |= LogError(
4706 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4707 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4708 }
Peter Chen85366392019-05-14 15:20:11 -04004709 }
4710
4711 return skip;
4712}
4713
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004714bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4715 uint32_t createInfoCount,
4716 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4717 const VkAllocationCallbacks *pAllocator,
4718 VkPipeline *pPipelines) const {
4719 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004720 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4721 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4722 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4723 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4724 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004725 for (uint32_t i = 0; i < createInfoCount; i++) {
4726 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4727 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4728 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4729 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4730 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4731 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4732 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4733 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004734 const auto *pipeline_cache_contol_features =
4735 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4736 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4737 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4738 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4739 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4740 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4741 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4742 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4743 }
4744 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004745 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4746 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4747 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4748 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4749 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4750 }
4751 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4752 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4753 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4754 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4755 }
4756 }
4757
sourav parmarf4a78252020-04-10 13:04:21 -07004758 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4759 skip |=
4760 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4761 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4762 }
4763 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4764 if (pCreateInfos[i].pLibraryInterface == NULL)
4765 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4766 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4767 }
4768 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4769 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4770 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4771 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4772 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4773 skip |= LogError(
4774 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4775 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4776 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4777 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4778 "must not be VK_SHADER_UNUSED_KHR");
4779 }
4780 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4781 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4782 skip |= LogError(
4783 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4784 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4785 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4786 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4787 "element must not be VK_SHADER_UNUSED_KHR");
4788 }
4789 }
4790 }
4791 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4792 if (pCreateInfos[i].basePipelineIndex != -1) {
4793 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4794 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4795 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4796 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4797 "and pCreateInfos->basePipelineIndex is not -1.");
4798 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004799 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4800 skip |=
4801 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4802 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4803 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4804 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4805 "element.");
4806 }
sourav parmarf4a78252020-04-10 13:04:21 -07004807 }
4808 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004809 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004810 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4811 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4812 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4813 "commands pCreateInfos parameter %d.",
4814 pCreateInfos[i].basePipelineIndex, createInfoCount);
4815 }
4816 } else {
4817 if (pCreateInfos[i].basePipelineIndex != -1) {
4818 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4819 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4820 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4821 }
4822 }
4823 }
4824 if (pCreateInfos[i].libraries.libraryCount == 0) {
4825 if (pCreateInfos[i].stageCount == 0) {
4826 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4827 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4828 }
4829 if (pCreateInfos[i].groupCount == 0) {
4830 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4831 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4832 }
4833 } else {
4834 if (pCreateInfos[i].pLibraryInterface == NULL) {
4835 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4836 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4837 }
4838 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004839 }
4840
4841 return skip;
4842}
4843
Mike Schuchardt21638df2019-03-16 10:52:02 -07004844#ifdef VK_USE_PLATFORM_WIN32_KHR
4845bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4846 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004847 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004848 bool skip = false;
4849 if (!device_extensions.vk_khr_swapchain)
4850 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4851 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4852 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4853 if (!device_extensions.vk_khr_surface)
4854 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4855 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4856 skip |=
4857 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4858 if (!device_extensions.vk_ext_full_screen_exclusive)
4859 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4860 skip |= validate_struct_type(
4861 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4862 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4863 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4864 if (pSurfaceInfo != NULL) {
4865 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4866 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4867 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4868
4869 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4870 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4871 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4872 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004873 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4874 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004875
4876 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4877 }
4878 return skip;
4879}
4880#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004881
4882bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4883 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004884 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004885 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4886 bool skip = false;
4887 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4888 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4889 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4890 }
4891 return skip;
4892}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004893
4894bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004895 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004896 bool skip = false;
4897
4898 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004899 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4900 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004901 }
4902
4903 return skip;
4904}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004905
4906bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004907 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004908 bool skip = false;
4909
4910 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004911 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4912 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004913 }
4914
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004915 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004916 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004917 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4918 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004919 }
4920
4921 return skip;
4922}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004923
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004924bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4925 uint32_t bindingCount, const VkBuffer *pBuffers,
4926 const VkDeviceSize *pOffsets) const {
4927 bool skip = false;
4928 if (firstBinding > device_limits.maxVertexInputBindings) {
4929 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4930 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4931 device_limits.maxVertexInputBindings);
4932 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4933 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4934 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4935 "maxVertexInputBindings (%u)",
4936 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4937 }
4938
Jeff Bolz165818a2020-05-08 11:19:03 -05004939 for (uint32_t i = 0; i < bindingCount; ++i) {
4940 if (pBuffers[i] == VK_NULL_HANDLE) {
4941 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4942 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4943 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4944 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4945 } else {
4946 if (pOffsets[i] != 0) {
4947 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4948 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4949 }
4950 }
4951 }
4952 }
4953
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004954 return skip;
4955}
4956
Mark Lobodzinski84988402019-09-11 15:27:30 -06004957bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004958 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004959 bool skip = false;
4960 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004961 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4962 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004963 }
4964 return skip;
4965}
4966
4967bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004968 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004969 bool skip = false;
4970 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004971 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4972 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004973 }
4974 return skip;
4975}
Petr Kraus3d720392019-11-13 02:52:39 +01004976
4977bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4978 VkSemaphore semaphore, VkFence fence,
4979 uint32_t *pImageIndex) const {
4980 bool skip = false;
4981
4982 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004983 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4984 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004985 }
4986
4987 return skip;
4988}
4989
4990bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4991 uint32_t *pImageIndex) const {
4992 bool skip = false;
4993
4994 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004995 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4996 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004997 }
4998
4999 return skip;
5000}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005001
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005002bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5003 uint32_t firstBinding, uint32_t bindingCount,
5004 const VkBuffer *pBuffers,
5005 const VkDeviceSize *pOffsets,
5006 const VkDeviceSize *pSizes) const {
5007 bool skip = false;
5008
5009 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5010 for (uint32_t i = 0; i < bindingCount; ++i) {
5011 if (pOffsets[i] & 3) {
5012 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5013 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5014 }
5015 }
5016
5017 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5018 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5019 "%s: The firstBinding(%" PRIu32
5020 ") index is greater than or equal to "
5021 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5022 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5023 }
5024
5025 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5026 skip |=
5027 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5028 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5029 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5030 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5031 }
5032
5033 for (uint32_t i = 0; i < bindingCount; ++i) {
5034 // pSizes is optional and may be nullptr.
5035 if (pSizes != nullptr) {
5036 if (pSizes[i] != VK_WHOLE_SIZE &&
5037 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5038 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5039 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5040 ") is not VK_WHOLE_SIZE and is greater than "
5041 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5042 cmd_name, i, pSizes[i]);
5043 }
5044 }
5045 }
5046
5047 return skip;
5048}
5049
5050bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5051 uint32_t firstCounterBuffer,
5052 uint32_t counterBufferCount,
5053 const VkBuffer *pCounterBuffers,
5054 const VkDeviceSize *pCounterBufferOffsets) const {
5055 bool skip = false;
5056
5057 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5058 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5059 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5060 "%s: The firstCounterBuffer(%" PRIu32
5061 ") index is greater than or equal to "
5062 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5063 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5064 }
5065
5066 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5067 skip |=
5068 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5069 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5070 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5071 cmd_name, firstCounterBuffer, counterBufferCount,
5072 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5073 }
5074
5075 return skip;
5076}
5077
5078bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5079 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5080 const VkBuffer *pCounterBuffers,
5081 const VkDeviceSize *pCounterBufferOffsets) const {
5082 bool skip = false;
5083
5084 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5085 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5086 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5087 "%s: The firstCounterBuffer(%" PRIu32
5088 ") index is greater than or equal to "
5089 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5090 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5091 }
5092
5093 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5094 skip |=
5095 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5096 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5097 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5098 cmd_name, firstCounterBuffer, counterBufferCount,
5099 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5100 }
5101
5102 return skip;
5103}
5104
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005105bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5106 uint32_t firstInstance, VkBuffer counterBuffer,
5107 VkDeviceSize counterBufferOffset,
5108 uint32_t counterOffset, uint32_t vertexStride) const {
5109 bool skip = false;
5110
5111 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005112 skip |= LogError(
5113 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005114 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5115 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5116 }
5117
5118 return skip;
5119}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005120
5121bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5122 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5123 const VkAllocationCallbacks *pAllocator,
5124 VkSamplerYcbcrConversion *pYcbcrConversion,
5125 const char *apiName) const {
5126 bool skip = false;
5127
5128 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005129 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005130 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005131 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5132 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5133 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005134 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005135 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005136 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005137
sfricke-samsung1a72f942020-07-25 12:09:18 -07005138 const VkFormat format = pCreateInfo->format;
sfricke-samsung83d98122020-07-04 06:21:15 -07005139 const VkComponentMapping components = pCreateInfo->components;
5140 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
sfricke-samsung1a72f942020-07-25 12:09:18 -07005141 if (FormatIsXChromaSubsampled(format) == true) {
sfricke-samsung83d98122020-07-04 06:21:15 -07005142 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5143 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
5144 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5145 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005146 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
sfricke-samsung83d98122020-07-04 06:21:15 -07005147 }
5148
5149 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5150 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5151 skip |=
5152 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5153 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5154 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005155 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
sfricke-samsung83d98122020-07-04 06:21:15 -07005156 }
5157
5158 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5159 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5160 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
5161 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5162 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005163 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
sfricke-samsung83d98122020-07-04 06:21:15 -07005164 }
5165
5166 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5167 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5168 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
5169 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5170 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005171 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
sfricke-samsung83d98122020-07-04 06:21:15 -07005172 }
5173
5174 // If one is identity, both need to be
5175 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5176 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5177 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5178 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
5179 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5180 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005181 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5182 string_VkComponentSwizzle(components.b));
5183 }
5184 }
5185
5186 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5187 // Checks same VU multiple ways in order to give a more useful error message
5188 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5189 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5190 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5191 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5192 skip |=
5193 LogError(device, vuid,
5194 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5195 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5196 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5197 string_VkComponentSwizzle(components.b));
5198 }
5199
5200 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5201 // 4 channel format = no issue
5202 // 3 = no [a]
5203 // 2 = no [b,a]
5204 // 1 = no [g,b,a]
5205 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5206 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5207
5208 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5209 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5210 skip |= LogError(device, vuid,
5211 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5212 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5213 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5214 string_VkComponentSwizzle(components.b));
5215 } else if ((channels < 3) &&
5216 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5217 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5218 skip |= LogError(device, vuid,
5219 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5220 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5221 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5222 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5223 string_VkComponentSwizzle(components.b));
5224 } else if ((channels < 2) &&
5225 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5226 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
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_G "
5230 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5231 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
sfricke-samsung83d98122020-07-04 06:21:15 -07005232 string_VkComponentSwizzle(components.b));
5233 }
5234 }
5235
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005236 return skip;
5237}
5238
5239bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5240 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5241 const VkAllocationCallbacks *pAllocator,
5242 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5243 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5244 "vkCreateSamplerYcbcrConversion");
5245}
5246
5247bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5248 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5249 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5250 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5251 "vkCreateSamplerYcbcrConversionKHR");
5252}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005253
5254bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5255 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5256 bool skip = false;
5257 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5258 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5259
5260 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005261 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5262 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5263 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5264 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5265 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005266 }
5267 return skip;
5268}
sourav parmara96ab1a2020-04-25 16:28:23 -07005269
5270bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5271 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5272 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005273 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5274 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5275 skip |=
5276 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5277 "vkCopyAccelerationStructureToMemoryKHR: the "
5278 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5279 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005280 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5281 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5282 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5283 }
5284 return skip;
5285}
5286
5287bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5288 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5289 bool skip = false;
5290 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5291 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5292 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5293 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5294 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005295 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5296 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005297 skip |= LogError(
5298 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5299 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5300 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5301 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005302 return skip;
5303}
5304
5305bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5306 const char *api_name) const {
5307 bool skip = false;
5308 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5309 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5310 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5311 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5312 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5313 api_name);
5314 }
5315 return skip;
5316}
5317
5318bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5319 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5320 bool skip = false;
5321 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005322 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5323 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5324 skip |= LogError(
5325 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5326 "vkCopyAccelerationStructureKHR(): the "
5327 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5328 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005329 return skip;
5330}
5331
5332bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5333 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5334 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005335 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5336 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005337 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5338 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5339 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5340 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005341 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5342 return skip;
5343}
5344
5345bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005346 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005347 bool skip = false;
5348 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005349 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005350 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005351 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005352 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5353 }
5354 return skip;
5355}
5356
5357bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5358 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5359 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005360 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5361 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5362 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5363 skip |=
5364 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5365 "vkCopyMemoryToAccelerationStructureKHR() :the "
5366 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5367 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005368 return skip;
5369}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005370
sourav parmara96ab1a2020-04-25 16:28:23 -07005371bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5372 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5373 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005374 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5375 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005376 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5377 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5378 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5379 }
sourav parmar83c31b12020-05-06 12:30:54 -07005380 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5381 return skip;
5382}
5383bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5384 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5385 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5386 bool skip = false;
5387 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5388 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5389 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5390 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5391 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5392 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5393 }
5394 return skip;
5395}
5396bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5397 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5398 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5399 bool skip = false;
5400 if (dataSize < accelerationStructureCount * stride) {
5401 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5402 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5403 "accelerationStructureCount (%d) *stride(%zu).",
5404 dataSize, accelerationStructureCount, stride);
5405 }
5406 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5407 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5408 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5409 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5410 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5411 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5412 }
5413 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5414 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5415 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5416 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5417 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5418 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5419 stride);
5420 }
5421 }
5422 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5423 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5424 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5425 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5426 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5427 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5428 stride);
5429 }
5430 }
5431 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5432 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5433 skip |=
5434 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5435 "vkWriteAccelerationStructuresPropertiesKHR: the "
5436 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5437 "feature must be enabled ");
5438 }
5439 return skip;
5440}
5441bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5442 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5443 bool skip = false;
5444 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5445 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5446 skip |= LogError(device,
5447 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5448 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5449 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5450 "must be enabled to call this function.");
5451 }
5452 return skip;
5453}
5454
5455bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5456 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5457 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5458 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5459 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5460 uint32_t width, uint32_t height, uint32_t depth) const {
5461 bool skip = false;
5462 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5463 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5464 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5465 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5466 }
5467 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5468 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5469 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5470 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5471 }
5472 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5473 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5474 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5475 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5476 }
5477 // hitShader
5478 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5479 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5480 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5481 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5482 }
5483 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5484 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5485 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5486 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5487 }
5488 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5489 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5490 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5491 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5492 }
5493
5494 // missShader
5495 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5496 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5497 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5498 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5499 }
5500 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5501 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5502 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5503 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5504 }
5505 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5506 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5507 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5508 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5509 }
5510
5511 // raygenShader
5512 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5513 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5514 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5515 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5516 }
5517 return skip;
5518}
5519
5520bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5521 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5522 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5523 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5524 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5525 VkBuffer buffer, VkDeviceSize offset) const {
5526 bool skip = false;
5527 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5528 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5529 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5530 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5531 "feature must be enabled.");
5532 }
5533 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5534 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5535 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5536 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5537 }
5538 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5539 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5540 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5541 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5542 }
5543 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5544 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5545 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5546 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5547 }
5548 // hitShader
5549 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5550 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5551 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5552 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5553 }
5554 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5555 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5556 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5557 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5558 }
5559 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5560 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5561 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5562 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5563 }
5564
5565 // missShader
5566 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5567 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5568 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5569 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5570 }
5571 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5572 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5573 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5574 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5575 }
5576 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5577 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5578 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5579 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5580 }
5581
5582 // raygenShader
5583 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5584 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5585 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5586 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5587 }
5588 return skip;
5589}
5590bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5591 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5592 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5593 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5594 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5595 uint32_t width, uint32_t height, uint32_t depth) const {
5596 bool skip = false;
5597 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5598 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5599 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5600 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5601 }
5602 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5603 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5604 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5605 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5606 }
5607 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5608 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5609 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5610 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5611 }
5612
5613 // hitShader
5614 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5615 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5616 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5617 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5618 }
5619 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5620 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5621 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5622 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5623 }
5624 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5625 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5626 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5627 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5628 }
5629
5630 // missShader
5631 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5632 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5633 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5634 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5635 }
5636 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5637 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5638 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5639 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5640 }
5641 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5642 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5643 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5644 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5645 }
5646
5647 // raygenShader
5648 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5649 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5650 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005651 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5652 }
5653 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5654 skip |=
5655 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5656 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5657 }
5658 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5659 skip |=
5660 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5661 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5662 }
5663 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5664 skip |=
5665 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5666 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005667 }
5668 return skip;
5669}
5670
5671bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5672 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5673 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5674 bool skip = false;
5675 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5676 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5677 skip |= LogError(
5678 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5679 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5680 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5681 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005682 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5683 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005684 skip |=
5685 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5686 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5687 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5688 }
5689 return false;
5690}
5691
5692bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5693 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5694 bool skip = false;
5695 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5696 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5697 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5698 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5699 }
5700 return skip;
5701}
5702
5703bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5704 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5705 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5706 bool skip = false;
5707 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5708 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005709 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5710 "vkBuildAccelerationStructureKHR: The "
5711 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5712 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005713 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005714 return skip;
5715}
sourav parmara24fb7b2020-05-26 10:50:04 -07005716bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5717 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5718 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5719 bool skip = false;
5720 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005721 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5722 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005723 skip |=
5724 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5725 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5726 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5727 }
5728 }
5729 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005730}
Piers Daniell39842ee2020-07-10 16:42:33 -06005731
5732bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5733 const VkViewport *pViewports) const {
5734 bool skip = false;
5735
5736 if (!physical_device_features.multiViewport) {
5737 if (viewportCount != 1) {
5738 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5739 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5740 ") is not 1.",
5741 viewportCount);
5742 }
5743 } else { // multiViewport enabled
5744 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5745 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5746 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5747 ") must "
5748 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5749 viewportCount, device_limits.maxViewports);
5750 }
5751 }
5752
5753 if (pViewports) {
5754 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5755 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5756 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5757 skip |= manual_PreCallValidateViewport(
5758 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5759 }
5760 }
5761
5762 return skip;
5763}
5764
5765bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5766 const VkRect2D *pScissors) const {
5767 bool skip = false;
5768
5769 if (!physical_device_features.multiViewport) {
5770 if (scissorCount != 1) {
5771 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5772 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5773 ") must "
5774 "be 1 when the multiViewport feature is disabled.",
5775 scissorCount);
5776 }
5777 } else { // multiViewport enabled
5778 if (scissorCount == 0) {
5779 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5780 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5781 ") must "
5782 "be great than zero.",
5783 scissorCount);
5784 } else if (scissorCount > device_limits.maxViewports) {
5785 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5786 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5787 ") must "
5788 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5789 scissorCount, device_limits.maxViewports);
5790 }
5791 }
5792
5793 if (pScissors) {
5794 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5795 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5796
5797 if (scissor.offset.x < 0) {
5798 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5799 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5800 scissor.offset.x);
5801 }
5802
5803 if (scissor.offset.y < 0) {
5804 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5805 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5806 scissor.offset.y);
5807 }
5808
5809 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5810 if (x_sum > INT32_MAX) {
5811 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5812 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5813 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5814 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5815 }
5816
5817 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5818 if (y_sum > INT32_MAX) {
5819 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5820 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5821 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5822 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5823 }
5824 }
5825 }
5826
5827 return skip;
5828}
5829
5830bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5831 uint32_t bindingCount, const VkBuffer *pBuffers,
5832 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5833 const VkDeviceSize *pStrides) const {
5834 bool skip = false;
5835 if (firstBinding >= device_limits.maxVertexInputBindings) {
5836 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5837 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5838 firstBinding, device_limits.maxVertexInputBindings);
5839 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5840 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5841 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5842 "maxVertexInputBindings (%u)",
5843 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5844 }
5845
5846 for (uint32_t i = 0; i < bindingCount; ++i) {
5847 if (pBuffers[i] == VK_NULL_HANDLE) {
5848 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5849 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5850 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5851 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5852 } else {
5853 if (pOffsets[i] != 0) {
5854 skip |=
5855 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5856 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5857 }
5858 }
5859 }
5860 if (pStrides) {
5861 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5862 skip |=
5863 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5864 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5865 pStrides[i], device_limits.maxVertexInputBindingStride);
5866 }
5867 }
5868 }
5869
5870 return skip;
5871}