blob: 9f2f891cbddebd7f54ae0c5098eb124f5eb9a059 [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
sfricke-samsungfd76c342020-05-29 23:13:43 -0700489 // feature dependencies for VK_KHR_multiview
490 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
491 VkBool32 multiview = VK_FALSE;
492 VkBool32 multiviewGeometryShader = VK_FALSE;
493 VkBool32 multiviewTessellationShader = VK_FALSE;
494 if (vulkan_11_features) {
495 multiview = vulkan_11_features->multiview;
496 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
497 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
498 } else if (multiview_features) {
499 multiview = multiview_features->multiview;
500 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
501 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
502 }
503 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
504 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
505 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
506 }
507 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
508 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
509 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
510 }
511
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600512 return skip;
513}
514
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500515bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700516 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700517 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
518 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
519 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700522 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523}
524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700525bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500526 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100527 bool skip = false;
528
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 skip |=
531 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532
533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
534 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
535 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
536 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
538 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
542 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
543 // queueFamilyIndexCount uint32_t values
544 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
546 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
548 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551
552 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
553 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
554 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
555 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700556 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
557 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
558 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600559 }
560 }
561
562 return skip;
563}
564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700565bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500566 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600568
569 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
571 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
572 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
573 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700574 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
575 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
576 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577 }
578
579 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
580 // queueFamilyIndexCount uint32_t values
581 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700582 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
583 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
584 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
585 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600586 }
587 }
588
Dave Houlton413a6782018-05-22 13:01:54 -0600589 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700590 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600591 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600593 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595
Dave Houlton413a6782018-05-22 13:01:54 -0600596 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700597 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600598 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600600
Dave Houlton130c0212018-01-29 13:39:56 -0700601 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700602 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
603 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(
605 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600606 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
607 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700608 }
609
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600610 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100611 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
612 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700613 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
614 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
615 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 }
617
618 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100619 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
620 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700621 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
622 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
623 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
624 ") are not equal.",
625 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100626 }
627
628 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
630 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
631 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
632 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100633 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
636 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(
638 device, "VUID-VkImageCreateInfo-imageType-00957",
639 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641 }
642
Dave Houlton130c0212018-01-29 13:39:56 -0700643 // 3D image may have only 1 layer
644 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
646 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700647 }
648
649 // If multi-sample, validate type, usage, tiling and mip levels.
650 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
651 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600652 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
654 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700655 }
656
657 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
658 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
659 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
660 // At least one of the legal attachment bits must be set
661 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700662 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
663 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700664 }
665 // No flags other than the legal attachment bits may be set
666 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
667 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
669 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700670 }
671 }
672
Jeff Bolzef40fec2018-09-01 22:04:34 -0500673 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500675 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600676 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
677 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500678 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600679 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
681 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
682 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600683 }
684
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600685 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700686 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
687 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
688 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600689 }
690
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700691 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700692 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
693 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
694 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100695 }
696
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
698 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
699 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
700 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
702 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
703 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
707 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
708 // Linear tiling is unsupported
709 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, kVUID_PVError_InvalidUsage,
711 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
712 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // Sparse 1D image isn't valid
716 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
718 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719 }
720
721 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700722 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
724 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
725 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600726 }
727
728 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700729 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
731 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
732 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600733 }
734
735 // Multi-sample 2D image when device doesn't support it
736 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700737 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600738 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
740 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
741 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700742 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
745 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
746 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700747 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600748 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
750 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
751 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700752 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
755 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
756 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600757 }
758 }
759 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500760
Jeff Bolz9af91c52018-09-01 21:53:57 -0500761 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
762 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700763 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
764 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
765 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500766 }
767 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
769 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
770 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500771 }
772 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
774 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
775 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500776 }
777 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500778
779 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600780 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
782 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
783 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 }
785
Dave Houlton142c4cb2018-10-17 15:04:41 -0600786 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
788 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
789 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
790 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500791 }
792
Dave Houlton142c4cb2018-10-17 15:04:41 -0600793 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
795 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
796 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
797 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500798 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600799 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
801 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
802 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
803 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 }
805 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500806
sfricke-samsung8f658d42020-05-03 20:12:24 -0700807 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
808 (FormatHasDepth(pCreateInfo->format) == false)) {
809 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
810 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
811 "format must be a depth or depth/stencil format.");
812 }
813
Andrew Fobel3abeb992020-01-20 16:33:22 -0500814 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
815 if (image_stencil_struct != nullptr) {
816 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
817 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
818 // No flags other than the legal attachment bits may be set
819 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
820 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
822 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
823 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
824 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500825 }
826 }
827
828 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
829 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
830 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
831 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
833 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
834 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
835 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500836 }
837
838 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
839 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 LogError(device, "VUID-VkImageCreateInfo-format-02537",
841 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
842 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
843 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500844 }
845 }
846
847 if (!physical_device_features.shaderStorageImageMultisample &&
848 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
849 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
850 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 LogError(device, "VUID-VkImageCreateInfo-format-02538",
852 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
853 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
854 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500855 }
856
857 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
858 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(
860 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500861 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
862 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
863 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
864 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
865 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(
867 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500868 "vkCreateImage(): Depth-stencil image in which usage does not include "
869 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
870 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
871 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
872 }
873
874 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
875 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(
877 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500878 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
879 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
880 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
881 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
882 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(
884 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500885 "vkCreateImage(): Depth-stencil image in which usage does not include "
886 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
887 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
888 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
889 }
890 }
891 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700892
893 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
894 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
895 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
896 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
897 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
898 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700899
900 if (device_extensions.vk_ext_image_drm_format_modifier) {
901 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
902 const auto drm_format_mod_explict =
903 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
904 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
905 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
906 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
907 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
908 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
909 "either VkImageDrmFormatModifierListCreateInfoEXT or "
910 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
911 }
912 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
913 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
914 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
915 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
916 "in the pNext chain");
917 }
918 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200919
920 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
921 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
923 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
924 "imageType must be VK_IMAGE_TYPE_2D.");
925 }
926 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
927 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
928 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
929 "samples must be VK_SAMPLE_COUNT_1_BIT.");
930 }
931 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
932 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
933 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
934 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
935 }
936 }
937 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
938 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
939 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
940 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
941 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
942 }
943 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
944 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
945 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
946 "imageType must be VK_IMAGE_TYPE_2D.");
947 }
948 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
950 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
951 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
952 }
953 if (pCreateInfo->mipLevels != 1) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
955 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
956 pCreateInfo->mipLevels);
957 }
958 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -0700959
960 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
961 if (swapchain_create_info != nullptr) {
962 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
963 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
964 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
965 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
966 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
967 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
968
969 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
970 // also implicitly forces the check above that extent.depth is 1
971 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
972 string_VkImageType(pCreateInfo->imageType));
973 }
974 if (pCreateInfo->mipLevels != 1) {
975 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
976 pCreateInfo->mipLevels);
977 }
978 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
979 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
980 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
981 }
982 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
983 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
984 base_message, string_VkImageTiling(pCreateInfo->tiling));
985 }
986 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
987 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
988 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
989 }
990 const VkImageCreateFlags valid_flags =
991 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
992 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
993 if ((pCreateInfo->flags & ~valid_flags) != 0) {
994 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
995 pCreateInfo->flags);
996 }
997 }
998 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600999 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001000
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001001 return skip;
1002}
1003
Jeff Bolz99e3f632020-03-24 22:59:22 -05001004bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1005 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1006 bool skip = false;
1007
1008 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001009 // Validate feature set if using CUBE_ARRAY
1010 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1011 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1012 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1013 "enabling the imageCubeArray feature.");
1014 }
1015
Jeff Bolz99e3f632020-03-24 22:59:22 -05001016 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1017 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1018 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001019 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001020 pCreateInfo->subresourceRange.layerCount);
1021 }
1022 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001023 skip |= LogError(
1024 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1025 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1026 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001027 }
1028 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001029
1030 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1031 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1032 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1033 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1034 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1035 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1036 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1037 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1038 }
1039 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1040 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1041 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1042 "not an ASTC format.",
1043 string_VkFormat(pCreateInfo->format));
1044 }
1045 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001046 }
1047 return skip;
1048}
1049
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001050bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001051 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001052 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001053
1054 // Note: for numerical correctness
1055 // - float comparisons should expect NaN (comparison always false).
1056 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1057
1058 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001059 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001060 if (v1_f <= 0.0f) return true;
1061
1062 float intpart;
1063 const float fract = modff(v1_f, &intpart);
1064
1065 assert(std::numeric_limits<float>::radix == 2);
1066 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1067 if (intpart >= u32_max_plus1) return false;
1068
1069 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1070 if (v1_u32 < v2_u32)
1071 return true;
1072 else if (v1_u32 == v2_u32 && fract == 0.0f)
1073 return true;
1074 else
1075 return false;
1076 };
1077
1078 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1079 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1080 return (v1_f <= v2_f);
1081 };
1082
1083 // width
1084 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001085 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001086
1087 if (!(viewport.width > 0.0f)) {
1088 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001089 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1090 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001091 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1092 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001093 skip |= LogError(object, "VUID-VkViewport-width-01771",
1094 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1095 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001096 } 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 -07001097 skip |= LogWarning(object, kVUID_PVError_NONE,
1098 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1099 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1100 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001101 }
1102
1103 // height
1104 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001105 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001106 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001107
1108 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1109 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001110 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1111 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001112 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1113 height_healthy = false;
1114
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001115 skip |= LogError(object, "VUID-VkViewport-height-01773",
1116 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1117 ").",
1118 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001119 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1120 height_healthy = false;
1121
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001122 skip |= LogWarning(
1123 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001124 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001125 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001126 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001127 }
1128
1129 // x
1130 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001131 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001132 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001133 skip |= LogError(object, "VUID-VkViewport-x-01774",
1134 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1135 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001136 }
1137
1138 // x + width
1139 if (x_healthy && width_healthy) {
1140 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001141 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001142 skip |= LogError(
1143 object, "VUID-VkViewport-x-01232",
1144 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1145 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1146 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001147 }
1148 }
1149
1150 // y
1151 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001152 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001153 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001154 skip |= LogError(object, "VUID-VkViewport-y-01775",
1155 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1156 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001157 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001158 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001159 skip |= LogError(object, "VUID-VkViewport-y-01776",
1160 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1161 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001162 }
1163
1164 // y + height
1165 if (y_healthy && height_healthy) {
1166 const float boundary = viewport.y + viewport.height;
1167
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001168 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001169 skip |= LogError(object, "VUID-VkViewport-y-01233",
1170 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1171 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1172 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001173 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001174 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001175 LogError(object, "VUID-VkViewport-y-01777",
1176 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1177 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1178 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001179 }
1180 }
1181
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001182 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001183 // minDepth
1184 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001185 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001186
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001187 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1188 "[0.0, 1.0] range.",
1189 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001190 }
1191
1192 // maxDepth
1193 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001194 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001195
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001196 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1197 "[0.0, 1.0] range.",
1198 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001199 }
1200 }
1201
1202 return skip;
1203}
1204
Dave Houlton142c4cb2018-10-17 15:04:41 -06001205struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001206 VkShadingRatePaletteEntryNV shadingRate;
1207 uint32_t width;
1208 uint32_t height;
1209};
1210
1211// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001212static SampleOrderInfo sampleOrderInfos[] = {
1213 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1214 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1215 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1216 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1217 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1218 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001219};
1220
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001221bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001222 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001223
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001224 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001225 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001226 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001227 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001228 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001229 break;
1230 }
1231 }
1232
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001233 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001234 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1235 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1236 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001237 return skip;
1238 }
1239
Dave Houlton142c4cb2018-10-17 15:04:41 -06001240 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001241 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001242 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1243 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1244 ") must "
1245 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1246 "is set in framebufferNoAttachmentsSampleCounts.",
1247 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001248 }
1249
Jeff Bolz9af91c52018-09-01 21:53:57 -05001250 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001251 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1252 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1253 ") must "
1254 "be equal to the product of sampleCount (=%" PRIu32
1255 "), the fragment width for shadingRate "
1256 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1257 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001258 }
1259
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001260 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001261 skip |= LogError(
1262 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001263 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1264 ") must "
1265 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001266 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001267 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001268
1269 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001270 // the first width*height*sampleCount bits to all be set. Note: There is no
1271 // guarantee that 64 bits is enough, but practically it's unlikely for an
1272 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001273 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001274 uint64_t sampleLocationsMask = 0;
1275 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1276 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1277 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001278 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1279 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001280 }
1281 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001282 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1283 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001284 }
1285 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001286 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1287 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001288 }
1289 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1290 sampleLocationsMask |= 1ULL << idx;
1291 }
1292
1293 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1294 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001295 skip |= LogError(
1296 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001297 "The array pSampleLocations must contain exactly one entry for "
1298 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001299 }
1300
1301 return skip;
1302}
1303
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001304bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1305 uint32_t createInfoCount,
1306 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1307 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001308 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001309 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001310
1311 if (pCreateInfos != nullptr) {
1312 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001313 bool has_dynamic_viewport = false;
1314 bool has_dynamic_scissor = false;
1315 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001316 bool has_dynamic_depth_bias = false;
1317 bool has_dynamic_blend_constant = false;
1318 bool has_dynamic_depth_bounds = false;
1319 bool has_dynamic_stencil_compare = false;
1320 bool has_dynamic_stencil_write = false;
1321 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001322 bool has_dynamic_viewport_w_scaling_nv = false;
1323 bool has_dynamic_discard_rectangle_ext = false;
1324 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001325 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001326 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001327 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001328 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001329 if (pCreateInfos[i].pDynamicState != nullptr) {
1330 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1331 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1332 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001333 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1334 if (has_dynamic_viewport == true) {
1335 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1336 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1337 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1338 i);
1339 }
1340 has_dynamic_viewport = true;
1341 }
1342 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1343 if (has_dynamic_scissor == true) {
1344 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1345 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1346 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1347 i);
1348 }
1349 has_dynamic_scissor = true;
1350 }
1351 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1352 if (has_dynamic_line_width == true) {
1353 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1354 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1355 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1356 i);
1357 }
1358 has_dynamic_line_width = true;
1359 }
1360 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1361 if (has_dynamic_depth_bias == true) {
1362 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1363 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1364 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1365 i);
1366 }
1367 has_dynamic_depth_bias = true;
1368 }
1369 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1370 if (has_dynamic_blend_constant == true) {
1371 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1372 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1373 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1374 i);
1375 }
1376 has_dynamic_blend_constant = true;
1377 }
1378 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1379 if (has_dynamic_depth_bounds == true) {
1380 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1381 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1382 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1383 i);
1384 }
1385 has_dynamic_depth_bounds = true;
1386 }
1387 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1388 if (has_dynamic_stencil_compare == true) {
1389 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1390 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1391 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1392 i);
1393 }
1394 has_dynamic_stencil_compare = true;
1395 }
1396 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1397 if (has_dynamic_stencil_write == true) {
1398 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1399 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1400 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1401 i);
1402 }
1403 has_dynamic_stencil_write = true;
1404 }
1405 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1406 if (has_dynamic_stencil_reference == true) {
1407 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1408 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1409 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1410 i);
1411 }
1412 has_dynamic_stencil_reference = true;
1413 }
1414 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1415 if (has_dynamic_viewport_w_scaling_nv == true) {
1416 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1417 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1418 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1419 i);
1420 }
1421 has_dynamic_viewport_w_scaling_nv = true;
1422 }
1423 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1424 if (has_dynamic_discard_rectangle_ext == true) {
1425 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1426 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1427 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1428 i);
1429 }
1430 has_dynamic_discard_rectangle_ext = true;
1431 }
1432 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1433 if (has_dynamic_sample_locations_ext == true) {
1434 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1435 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1436 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1437 i);
1438 }
1439 has_dynamic_sample_locations_ext = true;
1440 }
1441 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1442 if (has_dynamic_exclusive_scissor_nv == true) {
1443 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1444 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1445 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1446 i);
1447 }
1448 has_dynamic_exclusive_scissor_nv = true;
1449 }
1450 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1451 if (has_dynamic_shading_rate_palette_nv == true) {
1452 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1453 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1454 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1455 i);
1456 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001457 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001458 }
1459 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1460 if (has_dynamic_viewport_course_sample_order_nv == true) {
1461 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1462 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1463 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1464 i);
1465 }
1466 has_dynamic_viewport_course_sample_order_nv = true;
1467 }
1468 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1469 if (has_dynamic_line_stipple == true) {
1470 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1471 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1472 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1473 i);
1474 }
1475 has_dynamic_line_stipple = true;
1476 }
Petr Kraus299ba622017-11-24 03:09:03 +01001477 }
1478 }
1479
Peter Chen85366392019-05-14 15:20:11 -04001480 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1481 if ((feedback_struct != nullptr) &&
1482 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001483 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1484 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1485 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1486 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1487 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001488 }
1489
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001490 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001491
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001492 // Collect active stages and other information
1493 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001494 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001495 bool has_eval = false;
1496 bool has_control = false;
1497 if (pCreateInfos[i].pStages != nullptr) {
1498 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1499 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1500
1501 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1502 has_control = true;
1503 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1504 has_eval = true;
1505 }
1506
1507 skip |= validate_string(
1508 "vkCreateGraphicsPipelines",
1509 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1510 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1511 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001512 }
1513
1514 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1515 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1516 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1517 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1518 pCreateInfos[i].pTessellationState,
1519 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1520 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1521
1522 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1523 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1524
1525 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1526 "VkPipelineTessellationDomainOriginStateCreateInfo",
1527 pCreateInfos[i].pTessellationState->pNext,
1528 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1529 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001530 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1531 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001532
1533 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1534 pCreateInfos[i].pTessellationState->flags,
1535 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1536 }
1537
1538 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1539 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1540 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1541 pCreateInfos[i].pInputAssemblyState,
1542 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1543 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1544
1545 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1546 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001547 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001548
1549 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1550 pCreateInfos[i].pInputAssemblyState->flags,
1551 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1552
1553 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1554 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1555 pCreateInfos[i].pInputAssemblyState->topology,
1556 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1557
1558 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1559 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1560 }
1561
1562 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001563 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001564
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001565 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001566 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1567 "vkCreateGraphicsPipelines: pararameter "
1568 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1569 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001570 }
1571
1572 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1573 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1574 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1575 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1576 pCreateInfos[i].pVertexInputState->pNext, 1,
1577 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001578 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1579 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001580 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1581 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001582 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001583 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1584 skip |=
1585 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1586 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1587 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1588 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1589 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1590
1591 skip |= validate_array(
1592 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1593 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1594 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1595 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1596
1597 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1598 for (uint32_t vertexBindingDescriptionIndex = 0;
1599 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1600 ++vertexBindingDescriptionIndex) {
1601 skip |= validate_ranged_enum(
1602 "vkCreateGraphicsPipelines",
1603 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1604 AllVkVertexInputRateEnums,
1605 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1606 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1607 }
1608 }
1609
1610 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1611 for (uint32_t vertexAttributeDescriptionIndex = 0;
1612 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1613 ++vertexAttributeDescriptionIndex) {
1614 skip |= validate_ranged_enum(
1615 "vkCreateGraphicsPipelines",
1616 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1617 AllVkFormatEnums,
1618 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1619 "VUID-VkVertexInputAttributeDescription-format-parameter");
1620 }
1621 }
1622
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001623 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001624 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1625 "vkCreateGraphicsPipelines: pararameter "
1626 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1627 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1628 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001629 }
1630
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001631 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001632 skip |=
1633 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1634 "vkCreateGraphicsPipelines: pararameter "
1635 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1636 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1637 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001638 }
1639
1640 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001641 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1642 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001643 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1644 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001645 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1646 "vkCreateGraphicsPipelines: parameter "
1647 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1648 "(%" PRIu32 ") is not distinct.",
1649 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001650 }
1651 vertex_bindings.insert(vertex_bind_desc.binding);
1652
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001653 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001654 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1655 "vkCreateGraphicsPipelines: parameter "
1656 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1657 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1658 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001659 }
1660
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001661 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001662 skip |=
1663 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1664 "vkCreateGraphicsPipelines: parameter "
1665 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1666 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1667 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001668 }
1669 }
1670
Peter Kohautc7d9d392018-07-15 00:34:07 +02001671 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001672 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1673 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001674 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1675 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001676 skip |= LogError(
1677 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001678 "vkCreateGraphicsPipelines: parameter "
1679 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1680 i, d, vertex_attrib_desc.location);
1681 }
1682 attribute_locations.insert(vertex_attrib_desc.location);
1683
1684 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1685 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001686 skip |= LogError(
1687 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001688 "vkCreateGraphicsPipelines: parameter "
1689 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1690 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1691 i, d, vertex_attrib_desc.binding, i);
1692 }
1693
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001694 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001695 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1696 "vkCreateGraphicsPipelines: parameter "
1697 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1698 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1699 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001700 }
1701
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001702 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001703 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1704 "vkCreateGraphicsPipelines: parameter "
1705 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1706 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1707 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001708 }
1709
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001710 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001711 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1712 "vkCreateGraphicsPipelines: parameter "
1713 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1714 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1715 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001716 }
1717 }
1718 }
1719
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001720 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1721 if (has_control && has_eval) {
1722 if (pCreateInfos[i].pTessellationState == nullptr) {
1723 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1724 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1725 "shader stage and a tessellation evaluation shader stage, "
1726 "pCreateInfos[%d].pTessellationState must not be NULL.",
1727 i, i);
1728 } else {
1729 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1730 skip |= validate_struct_pnext(
1731 "vkCreateGraphicsPipelines",
1732 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1733 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1734 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1735 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001736
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001737 skip |= validate_reserved_flags(
1738 "vkCreateGraphicsPipelines",
1739 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1740 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001741
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001742 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1743 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1744 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1745 "vkCreateGraphicsPipelines: invalid parameter "
1746 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1747 "should be >0 and <=%u.",
1748 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1749 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001750 }
1751 }
1752 }
1753
1754 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1755 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1756 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1757 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001758 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1759 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1760 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1761 "].pViewportState (=NULL) is not a valid pointer.",
1762 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001763 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001764 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1765
1766 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001767 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1768 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1769 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1770 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001771 }
1772
Petr Krausa6103552017-11-16 21:21:58 +01001773 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1774 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001775 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1776 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001777 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1778 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001779 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001780 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001781 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001782 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001783 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001784 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1785 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001786 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001787 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1788 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001789
1790 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001791 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001792 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001793 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001794
Dave Houlton142c4cb2018-10-17 15:04:41 -06001795 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1796 pCreateInfos[i].pViewportState->pNext);
1797 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1798 pCreateInfos[i].pViewportState->pNext);
1799 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1800 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001801 const auto vp_swizzle_struct =
1802 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001803 const auto vp_w_scaling_struct =
1804 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001805
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001806 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001807 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001808 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1809 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1810 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1811 ") is not 1.",
1812 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001813 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001814
Petr Krausa6103552017-11-16 21:21:58 +01001815 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001816 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1817 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1818 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1819 ") is not 1.",
1820 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001821 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001822
Dave Houlton142c4cb2018-10-17 15:04:41 -06001823 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1824 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001825 skip |= LogError(
1826 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1827 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1828 "disabled, but pCreateInfos[%" PRIu32
1829 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1830 ") is not 1.",
1831 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001832 }
1833
Jeff Bolz9af91c52018-09-01 21:53:57 -05001834 if (shading_rate_image_struct &&
1835 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001836 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1837 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1838 "disabled, but pCreateInfos[%" PRIu32
1839 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1840 ") is neither 0 nor 1.",
1841 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001842 }
1843
Petr Krausa6103552017-11-16 21:21:58 +01001844 } else { // multiViewport enabled
1845 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001846 skip |= LogError(
1847 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001848 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001849 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001850 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1851 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1852 "].pViewportState->viewportCount (=%" PRIu32
1853 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1854 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001855 }
Petr Krausa6103552017-11-16 21:21:58 +01001856
1857 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001858 skip |= LogError(
1859 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001860 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001861 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001862 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1863 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1864 "].pViewportState->scissorCount (=%" PRIu32
1865 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1866 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001867 }
1868 }
1869
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001870 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 skip |=
1872 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1873 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1874 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1875 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001876 }
1877
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001878 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001879 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1880 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1881 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1882 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1883 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001884 }
1885
Petr Krausa6103552017-11-16 21:21:58 +01001886 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001887 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1888 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1889 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1890 "].pViewportState->viewportCount (=%" PRIu32 ").",
1891 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001892 }
1893
Dave Houlton142c4cb2018-10-17 15:04:41 -06001894 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001895 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001896 skip |=
1897 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1898 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1899 ") must be zero or identical to pCreateInfos[%" PRIu32
1900 "].pViewportState->viewportCount (=%" PRIu32 ").",
1901 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001902 }
1903
Dave Houlton142c4cb2018-10-17 15:04:41 -06001904 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001905 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001906 skip |= LogError(
1907 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001908 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1909 "] "
1910 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1911 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1912 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001913 }
1914
Petr Krausa6103552017-11-16 21:21:58 +01001915 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001916 skip |= LogError(
1917 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001918 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1919 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001920 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1921 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001922 }
1923
1924 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001925 skip |= LogError(
1926 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001927 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1928 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001929 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1930 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001931 }
1932
Jeff Bolz3e71f782018-08-29 23:15:45 -05001933 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001934 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1935 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1936 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06001937 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001938 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1939 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1940 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1941 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001942 }
1943
Jeff Bolz9af91c52018-09-01 21:53:57 -05001944 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001945 shading_rate_image_struct->viewportCount > 0 &&
1946 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001947 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06001948 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001949 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001950 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1951 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001952 i, i);
1953 }
1954
Chris Mayer328d8212018-12-11 14:16:18 +01001955 if (vp_swizzle_struct) {
1956 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001957 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1958 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1959 " does "
1960 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1961 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001962 }
1963 }
1964
Petr Krausb3fcdb42018-01-09 22:09:09 +01001965 // validate the VkViewports
1966 if (!has_dynamic_viewport && viewport_state.pViewports) {
1967 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1968 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001969 const char *fn_name = "vkCreateGraphicsPipelines";
1970 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1971 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1972 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001973 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001974 }
1975 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001976
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001977 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001978 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1979 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1980 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1981 "VK_NV_clip_space_w_scaling extension is not enabled.",
1982 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001983 }
1984
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001985 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001986 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1987 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1988 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1989 "VK_EXT_discard_rectangles extension is not enabled.",
1990 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001991 }
1992
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001994 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1995 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1996 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1997 "VK_EXT_sample_locations extension is not enabled.",
1998 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001999 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002000
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002001 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002002 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2003 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2004 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2005 "VK_NV_scissor_exclusive extension is not enabled.",
2006 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002007 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002008
2009 if (coarse_sample_order_struct &&
2010 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2011 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002012 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2013 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2014 "] "
2015 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2016 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2017 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002018 }
2019
2020 if (coarse_sample_order_struct) {
2021 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002022 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002023 }
2024 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002025
2026 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2027 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002028 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2029 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2030 "] "
2031 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2032 ") "
2033 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2034 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002035 }
2036 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002037 skip |= LogError(
2038 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002039 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2040 "] "
2041 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2042 i);
2043 }
2044 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002045 }
2046
2047 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002048 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2049 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2050 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2051 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002052 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002053 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
2054 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2055 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002056 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002057 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002058 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002059 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002060 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002061 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002062 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002063 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2064 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065
2066 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002067 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002068 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002069 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002070
2071 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002072 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002073 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2074 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2075
2076 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002077 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002078 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2079 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002080 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002081 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002082
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002083 skip |= validate_flags(
2084 "vkCreateGraphicsPipelines",
2085 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2086 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002087 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002088
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002089 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002090 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002091 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2092 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2093
2094 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002095 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002096 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2097 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2098
2099 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002100 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2101 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2102 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2103 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002104 }
John Zulauf7acac592017-11-06 11:15:53 -07002105 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002106 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002107 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2108 "vkCreateGraphicsPipelines(): parameter "
2109 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2110 i);
John Zulauf7acac592017-11-06 11:15:53 -07002111 }
2112 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2113 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2114 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002115 skip |= LogError(
2116 device,
2117
Dave Houlton413a6782018-05-22 13:01:54 -06002118 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002119 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002120 }
2121 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002122
2123 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2124 pCreateInfos[i].pRasterizationState->pNext);
2125
2126 if (line_state) {
2127 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2128 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2129 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2130 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002131 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2132 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2133 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2134 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002135 }
2136 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2137 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002138 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2139 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2140 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2141 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002142 }
2143 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2144 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002145 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2146 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2147 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2148 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002149 }
2150 }
2151 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2152 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2153 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002154 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2155 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2156 "range [1,256].",
2157 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002158 }
2159 }
2160 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002161 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002162 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2163 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002164 skip |=
2165 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2166 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2167 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2168 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002169 }
2170 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2171 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 skip |=
2173 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2174 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2175 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2176 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002177 }
2178 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2179 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002180 skip |=
2181 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2182 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2183 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2184 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002185 }
2186 if (line_state->stippledLineEnable) {
2187 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2188 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002189 skip |=
2190 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2191 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2192 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2193 "stippledRectangularLines feature.",
2194 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002195 }
2196 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2197 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002198 skip |=
2199 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2200 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2201 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2202 "stippledBresenhamLines feature.",
2203 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002204 }
2205 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2206 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002207 skip |=
2208 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2209 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2210 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2211 "stippledSmoothLines feature.",
2212 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002213 }
2214 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2215 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002216 skip |=
2217 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2218 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2219 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2220 "stippledRectangularLines and strictLines features.",
2221 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002222 }
2223 }
2224 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225 }
2226
Petr Krause91f7a12017-12-14 20:57:36 +01002227 bool uses_color_attachment = false;
2228 bool uses_depthstencil_attachment = false;
2229 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002230 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2232 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002233 const auto &subpasses_uses = subpasses_uses_it->second;
2234 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2235 uses_color_attachment = true;
2236 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2237 uses_depthstencil_attachment = true;
2238 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002239 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002240 }
2241
2242 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002243 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002244 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002246 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002247 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002248
2249 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002250 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002252 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253
2254 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002255 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2257 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2258
2259 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002260 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2262 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2263
2264 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002265 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2267 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002268 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269
2270 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002271 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002272 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2273 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2274
2275 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002276 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002277 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2278 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2279
2280 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002281 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2283 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002284 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002285
2286 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002287 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002288 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2289 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002290 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291
2292 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002293 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002294 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2295 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002296 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297
2298 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002299 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002300 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2301 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002302 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303
2304 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002305 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2307 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002308 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002309
2310 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002311 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002312 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2313 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002314 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315
2316 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002317 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2319 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002320 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321
2322 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002323 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002324 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2325 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002326 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327
2328 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002329 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2330 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2331 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2332 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002333 }
2334 }
2335
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002336 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2337 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2338
Petr Krause91f7a12017-12-14 20:57:36 +01002339 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002340 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2341 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2342 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2343 pCreateInfos[i].pColorBlendState,
2344 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2345 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2346
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002347 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002348 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002349 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2350 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2351 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002352 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002353 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2354 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002355
2356 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002357 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002358 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002359 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360
2361 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002362 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2364 pCreateInfos[i].pColorBlendState->logicOpEnable);
2365
2366 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002367 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002368 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2369 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002370 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002371 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002372
2373 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2374 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2375 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002376 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002377 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2378 ParameterName::IndexVector{i, attachmentIndex}),
2379 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2380
2381 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002382 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2384 ParameterName::IndexVector{i, attachmentIndex}),
2385 "VkBlendFactor", AllVkBlendFactorEnums,
2386 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002387 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388
2389 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002390 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002391 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2392 ParameterName::IndexVector{i, attachmentIndex}),
2393 "VkBlendFactor", AllVkBlendFactorEnums,
2394 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002395 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396
2397 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002398 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002399 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2400 ParameterName::IndexVector{i, attachmentIndex}),
2401 "VkBlendOp", AllVkBlendOpEnums,
2402 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002403 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002404
2405 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002406 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002407 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2408 ParameterName::IndexVector{i, attachmentIndex}),
2409 "VkBlendFactor", AllVkBlendFactorEnums,
2410 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002411 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002412
2413 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002414 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002415 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2416 ParameterName::IndexVector{i, attachmentIndex}),
2417 "VkBlendFactor", AllVkBlendFactorEnums,
2418 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002419 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002420
2421 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002422 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002423 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2424 ParameterName::IndexVector{i, attachmentIndex}),
2425 "VkBlendOp", AllVkBlendOpEnums,
2426 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002427 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002428
2429 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002430 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002431 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2432 ParameterName::IndexVector{i, attachmentIndex}),
2433 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2434 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002435 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
2437 }
2438
2439 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002440 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2441 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2442 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2443 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444 }
2445
2446 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2447 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2448 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002449 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002450 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002451 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2452 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002453 }
2454 }
2455 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002456
Petr Kraus9752aae2017-11-24 03:05:50 +01002457 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2458 if (pCreateInfos[i].basePipelineIndex != -1) {
2459 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002460 skip |=
2461 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002462 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002463 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002464 "and pCreateInfos->basePipelineIndex is not -1.",
2465 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 }
2467 }
2468
Petr Kraus9752aae2017-11-24 03:05:50 +01002469 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2470 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002471 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002472 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002473 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002474 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2475 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002477 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002478 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002479 skip |=
2480 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2481 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2482 "index into the pCreateInfos array, of size %d.",
2483 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002484 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485 }
2486 }
2487
sfricke-samsung898cf222020-05-15 23:10:19 -07002488 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2489 skip |= LogError(
2490 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2491 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2492 i);
2493 }
2494
Petr Kraus9752aae2017-11-24 03:05:50 +01002495 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002496 if (!device_extensions.vk_nv_fill_rectangle) {
2497 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2498 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2500 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2501 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2502 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002503 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2504 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2506 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002507 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2508 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2509 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002510 }
2511 } else {
2512 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2513 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2514 (physical_device_features.fillModeNonSolid == false)) {
2515 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002516 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2517 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002518 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2519 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2520 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002521 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002522 }
Petr Kraus299ba622017-11-24 03:09:03 +01002523
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002524 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002525 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002526 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2527 "The line width state is static (pCreateInfos[%" PRIu32
2528 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2529 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2530 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2531 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002532 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002533 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002534 }
2535 }
2536
2537 return skip;
2538}
2539
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002540bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2541 uint32_t createInfoCount,
2542 const VkComputePipelineCreateInfo *pCreateInfos,
2543 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002544 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002545 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002546 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002547 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002548 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002549 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002550 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2551 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002552 skip |=
2553 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2554 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2555 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2556 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002557 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002558
2559 // Make sure compute stage is selected
2560 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002561 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2562 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2563 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002564 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002565 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002566 return skip;
2567}
2568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002570 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002571 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572
2573 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002574 const auto &features = physical_device_features;
2575 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002576
John Zulauf71968502017-10-26 13:51:15 -06002577 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2578 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002579 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2580 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2581 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2582 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002583 }
2584
2585 // Anistropy cannot be enabled in sampler unless enabled as a feature
2586 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002587 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2588 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2589 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002590 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002591 }
John Zulauf71968502017-10-26 13:51:15 -06002592
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002593 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2594 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002595 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2596 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2597 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2598 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002599 }
2600 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002601 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2602 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2603 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2604 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002605 }
2606 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002607 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2608 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2609 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2610 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002611 }
2612 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2613 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2614 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2615 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002616 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2617 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2618 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2619 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2620 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2621 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002622 }
2623 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002624 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2625 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2626 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002627 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002628 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002629 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2630 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2631 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002632 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002633 }
2634
2635 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2636 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002637 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2638 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002639 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2640 if (sampler_reduction != nullptr) {
2641 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2642 skip |= LogError(
2643 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2644 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2645 }
2646 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002647 }
2648
2649 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2650 // valid VkBorderColor value
2651 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2652 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2653 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002654 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2655 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002656 }
2657
2658 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2659 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002660 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002661 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2662 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2663 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002664 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002665 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2666 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2667 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002668 }
John Zulauf275805c2017-10-26 15:34:49 -06002669
2670 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002671 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002672 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2673 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002674 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2675 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2676 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002677 }
2678 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002679
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002680 // Check for valid Lod range
2681 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002682 skip |=
2683 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2684 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002685 }
2686
2687 // Check mipLodBias to device limit
2688 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002689 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2690 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2691 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002692 }
2693
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002694 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2695 if (sampler_conversion != nullptr) {
2696 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2697 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2698 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2699 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002701 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002702 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2703 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2704 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2705 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2706 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2707 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2708 }
2709 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002710
2711 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2712 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2713 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2714 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2715 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2716 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2717 }
2718 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2719 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2720 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2721 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2722 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2723 }
2724 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2725 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2726 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2727 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2728 pCreateInfo->minLod, pCreateInfo->maxLod);
2729 }
2730 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2731 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2732 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2733 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2734 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2735 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2736 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2737 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2738 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2739 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2740 }
2741 if (pCreateInfo->anisotropyEnable) {
2742 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2743 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2744 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2745 }
2746 if (pCreateInfo->compareEnable) {
2747 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2748 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2749 "pCreateInfo->compareEnable must be VK_FALSE");
2750 }
2751 if (pCreateInfo->unnormalizedCoordinates) {
2752 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2753 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2754 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2755 }
2756 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 }
2758
Tony-LunarG7337b312020-04-15 16:40:25 -06002759 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2760 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2761 if (!device_extensions.vk_ext_custom_border_color) {
2762 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2763 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2764 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2765 }
2766 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2767 if (!custom_create_info) {
2768 skip |=
2769 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2770 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2771 "struct in pNext chain.\n",
2772 string_VkBorderColor(pCreateInfo->borderColor));
2773 } else {
2774 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2775 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2776 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2777 !FormatIsSampledFloat(custom_create_info->format)))) {
2778 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2779 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2780 "whose type does not match\n",
2781 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2782 ;
2783 }
2784 }
2785 }
2786
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002787 return skip;
2788}
2789
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002790bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2791 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2792 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002793 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002794 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002795
2796 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2797 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2798 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2799 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002800 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2801 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2802 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2803 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2804 ++descriptor_index) {
2805 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002806 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 "vkCreateDescriptorSetLayout: required parameter "
2808 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2809 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002810 }
2811 }
2812 }
2813
2814 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2815 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2816 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002817 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2818 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2819 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2820 "values.",
2821 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002823
2824 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2825 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2826 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2827 skip |=
2828 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2829 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2830 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2831 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2832 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2833 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002834 }
2835 }
2836 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002837 return skip;
2838}
2839
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002840bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2841 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002842 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2844 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2845 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002846 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2847 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848}
2849
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002850bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2851 const VkWriteDescriptorSet *pDescriptorWrites,
2852 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002853 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002854
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855 if (pDescriptorWrites != NULL) {
2856 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2857 // descriptorCount must be greater than 0
2858 if (pDescriptorWrites[i].descriptorCount == 0) {
2859 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002860 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2861 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 }
2863
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002864 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2865 if (validateDstSet) {
2866 // dstSet must be a valid VkDescriptorSet handle
2867 skip |= validate_required_handle(vkCallingFunction,
2868 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2869 pDescriptorWrites[i].dstSet);
2870 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002871
2872 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2873 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2874 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2875 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2876 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2877 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2878 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002879 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2880 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002881 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002882 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2883 "%s(): if pDescriptorWrites[%d].descriptorType is "
2884 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2885 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2886 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2887 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2889 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002890 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2891 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2893 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002894 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002895 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2896 ParameterName::IndexVector{i, descriptor_index}),
2897 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002898 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002899 }
2900 }
2901 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2902 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2903 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2904 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2905 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2906 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2907 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002908 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002909 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002910 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2911 "%s(): if pDescriptorWrites[%d].descriptorType is "
2912 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2913 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2914 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2915 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002917 const auto *robustness2_features =
2918 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2919 if (robustness2_features && robustness2_features->nullDescriptor) {
2920 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2921 ++descriptorIndex) {
2922 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2923 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2924 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2925 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2926 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2927 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2928 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2929 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2930 }
2931 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002932 }
2933 }
2934 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2935 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002936 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002937 }
2938
2939 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2940 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002941 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002942 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2943 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2944 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002945 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002946 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2947 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2948 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2949 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002950 }
2951 }
2952 }
2953 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2954 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002955 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002956 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2957 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2958 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002959 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002960 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2961 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2962 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2963 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002964 }
2965 }
2966 }
2967 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002968 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2969 // or VkWriteDescriptorSetInlineUniformBlockEX
2970 if (pDescriptorWrites[i].pNext) {
2971 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002972 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07002973 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002974 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002975 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2976 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2977 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2978 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002979 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07002980 pDescriptorWrites[i].descriptorCount);
2981 }
2982 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002983 if (pnext_struct) {
2984 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002985 skip |= LogError(
2986 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2987 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2988 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002989 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07002990 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002991 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002992 skip |= LogError(
2993 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2994 "%s(): accelerationStructureCount must be greater than 0 .");
2995 }
2996 }
2997 }
2998 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002999 }
3000 }
3001 return skip;
3002}
3003
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003004bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3005 const VkWriteDescriptorSet *pDescriptorWrites,
3006 uint32_t descriptorCopyCount,
3007 const VkCopyDescriptorSet *pDescriptorCopies) const {
3008 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3009}
3010
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003011bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003012 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003013 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003014 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3015}
3016
3017bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003018 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003019 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003020 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3021}
3022
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003023bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3024 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003025 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003026 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027
3028 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3029 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3030 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003031 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3032 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003033 return skip;
3034}
3035
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003036bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003037 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003039
3040 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3041 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003042 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3043
Petr Krause7bb9e82019-08-11 21:34:43 +02003044 // Implicit VUs
3045 // validate only sType here; pointer has to be validated in core_validation
3046 const bool kNotRequired = false;
3047 const char *kNoVUID = nullptr;
3048 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3049 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3050 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003051
Petr Krause7bb9e82019-08-11 21:34:43 +02003052 if (pInfo) {
3053 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3054 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3055 skip |= validate_struct_pnext(
3056 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3057 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003058 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3059 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060
Petr Krause7bb9e82019-08-11 21:34:43 +02003061 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062
Petr Krause7bb9e82019-08-11 21:34:43 +02003063 // Explicit VUs
3064 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003065 skip |= LogError(
3066 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003067 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3068 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003070
3071 if (physical_device_features.inheritedQueries) {
3072 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003073 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003074 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003075 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003076 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003077 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003078 }
3079
3080 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003081 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003082 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003083 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003084 } else { // !pipelineStatisticsQuery
3085 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3086 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 }
Petr Kraus139757b2019-08-15 17:19:33 +02003088
3089 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3090 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003091 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003092 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3093 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 skip |= LogError(
3095 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003096 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3097 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3098 }
3099 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003100 }
3101
3102 return skip;
3103}
3104
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003105bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003106 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003108
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003109 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003110 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003111 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3112 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3113 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003114 }
3115 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003116 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3117 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3118 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003119 }
3120 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003121 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003122 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003123 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3124 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3125 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3126 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127 }
3128 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003129
3130 if (pViewports) {
3131 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3132 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003133 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003134 skip |= manual_PreCallValidateViewport(
3135 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003136 }
3137 }
3138
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003139 return skip;
3140}
3141
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003142bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003143 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003144 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003145
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003146 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003147 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003148 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3149 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3150 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003151 }
3152 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3154 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3155 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003156 }
3157 } else { // multiViewport enabled
3158 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003159 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003160 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3161 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3162 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3163 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003164 }
3165 }
3166
Petr Kraus6260f0a2018-02-27 21:15:55 +01003167 if (pScissors) {
3168 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3169 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170
Petr Kraus6260f0a2018-02-27 21:15:55 +01003171 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003172 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3173 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3174 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003175 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003176
Petr Kraus6260f0a2018-02-27 21:15:55 +01003177 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003178 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3179 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3180 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003181 }
3182
3183 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3184 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003185 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3186 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3187 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3188 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003189 }
3190
3191 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3192 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003193 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3194 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3195 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3196 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003197 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003198 }
3199 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003200
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003201 return skip;
3202}
3203
Jeff Bolz5c801d12019-10-09 10:38:45 -05003204bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003205 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003206
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003207 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003208 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3209 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003210 }
3211
3212 return skip;
3213}
3214
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003215bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003216 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003217 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003218 if (vertexCount == 0) {
3219 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3220 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003221 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003222 }
3223
3224 if (instanceCount == 0) {
3225 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3226 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003227 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003228 }
3229 return skip;
3230}
3231
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003232bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003233 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003234 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003236 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003237 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3238 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 }
3240 return skip;
3241}
3242
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003243bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003244 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003245 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003246 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003247 skip |=
3248 LogError(device, kVUID_PVError_DeviceFeature,
3249 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003250 }
3251 return skip;
3252}
3253
sfricke-samsungf692b972020-05-02 08:00:45 -07003254bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3255 VkDeviceSize countBufferOffset, bool khr) const {
3256 bool skip = false;
3257 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3258 if (offset & 3) {
3259 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3260 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3261 }
3262
3263 if (countBufferOffset & 3) {
3264 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3265 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3266 countBufferOffset);
3267 }
3268 return skip;
3269}
3270
3271bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3272 VkDeviceSize offset, VkBuffer countBuffer,
3273 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3274 uint32_t stride) const {
3275 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3276}
3277
3278bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3279 VkDeviceSize offset, VkBuffer countBuffer,
3280 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3281 uint32_t stride) const {
3282 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3283}
3284
3285bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3286 VkDeviceSize countBufferOffset, bool khr) const {
3287 bool skip = false;
3288 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3289 if (offset & 3) {
3290 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3291 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3292 }
3293
3294 if (countBufferOffset & 3) {
3295 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3296 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3297 countBufferOffset);
3298 }
3299 return skip;
3300}
3301
3302bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3303 VkDeviceSize offset, VkBuffer countBuffer,
3304 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3305 uint32_t stride) const {
3306 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3307}
3308
3309bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3310 VkDeviceSize offset, VkBuffer countBuffer,
3311 VkDeviceSize countBufferOffset,
3312 uint32_t maxDrawCount, uint32_t stride) const {
3313 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3314}
3315
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003316bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3317 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003318 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003319 bool skip = false;
3320 for (uint32_t rect = 0; rect < rectCount; rect++) {
3321 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3323 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003324 }
sfricke-samsung10867682020-04-25 02:20:39 -07003325 if (pRects[rect].rect.extent.width == 0) {
3326 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3327 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3328 }
3329 if (pRects[rect].rect.extent.height == 0) {
3330 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3331 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3332 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003333 }
3334 return skip;
3335}
3336
Andrew Fobel3abeb992020-01-20 16:33:22 -05003337bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3338 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3339 VkImageFormatProperties2 *pImageFormatProperties,
3340 const char *apiName) const {
3341 bool skip = false;
3342
3343 if (pImageFormatInfo != nullptr) {
3344 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3345 if (image_stencil_struct != nullptr) {
3346 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3347 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3348 // No flags other than the legal attachment bits may be set
3349 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3350 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003351 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3352 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3353 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3354 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3355 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003356 }
3357 }
3358 }
3359 }
3360
3361 return skip;
3362}
3363
3364bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3365 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3366 VkImageFormatProperties2 *pImageFormatProperties) const {
3367 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3368 "vkGetPhysicalDeviceImageFormatProperties2");
3369}
3370
3371bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3372 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3373 VkImageFormatProperties2 *pImageFormatProperties) const {
3374 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3375 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3376}
3377
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003378bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3379 VkImageLayout srcImageLayout, VkImage dstImage,
3380 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003381 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003383
Dave Houltonf5217612018-02-02 16:18:52 -07003384 VkImageAspectFlags legal_aspect_flags =
3385 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 -07003386 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003387 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3388 }
3389
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003390 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003391 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003392 skip |= LogError(
3393 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003394 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003395 }
Dave Houltonf5217612018-02-02 16:18:52 -07003396 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003397 skip |= LogError(
3398 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003399 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003400 }
3401 }
3402 return skip;
3403}
3404
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003405bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3406 VkImageLayout srcImageLayout, VkImage dstImage,
3407 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003408 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003409 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003410
Dave Houltonf5217612018-02-02 16:18:52 -07003411 VkImageAspectFlags legal_aspect_flags =
3412 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 -07003413 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003414 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3415 }
3416
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003418 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003419 skip |= LogError(
3420 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003421 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3422 }
Dave Houltonf5217612018-02-02 16:18:52 -07003423 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(
3425 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003426 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3427 }
3428 }
3429 return skip;
3430}
3431
sfricke-samsung3999ef62020-02-09 17:05:59 -08003432bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3433 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3434 bool skip = false;
3435
3436 if (pRegions != nullptr) {
3437 for (uint32_t i = 0; i < regionCount; i++) {
3438 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003439 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3440 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003441 }
3442 }
3443 }
3444 return skip;
3445}
3446
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003447bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3448 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003449 uint32_t regionCount,
3450 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003452
Dave Houltonf5217612018-02-02 16:18:52 -07003453 VkImageAspectFlags legal_aspect_flags =
3454 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 -07003455 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003456 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3457 }
3458
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003459 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003460 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003461 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3462 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3463 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003464 }
3465 }
3466 return skip;
3467}
3468
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003469bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3470 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003471 uint32_t regionCount,
3472 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003473 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003474
Dave Houltonf5217612018-02-02 16:18:52 -07003475 VkImageAspectFlags legal_aspect_flags =
3476 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 -07003477 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003478 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3479 }
3480
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003482 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003483 skip |= LogError(
3484 device, kVUID_PVError_UnrecognizedValue,
3485 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3486 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487 }
3488 }
3489 return skip;
3490}
3491
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003492bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003493 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3494 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003495 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003496
3497 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003498 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3499 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3500 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003501 }
3502
3503 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003504 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3505 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3506 "), must be greater than zero and less than or equal to 65536.",
3507 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003508 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3510 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3511 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512 }
3513 return skip;
3514}
3515
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003516bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003517 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003518 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003519
3520 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003521 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3522 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3523 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003524 }
3525
3526 if (size != VK_WHOLE_SIZE) {
3527 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003528 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003529 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3530 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003531 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003532 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3533 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003534 }
3535 }
3536 return skip;
3537}
3538
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003539bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003540 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003541 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003542 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003543
3544 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003545 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3546 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3547 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3548 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003549 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3550 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3551 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003552 }
3553
3554 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3555 // queueFamilyIndexCount uint32_t values
3556 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003557 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3558 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3559 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3560 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003561 }
3562 }
3563
Dave Houlton413a6782018-05-22 13:01:54 -06003564 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003565 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003566 }
3567
3568 return skip;
3569}
3570
Jeff Bolz5c801d12019-10-09 10:38:45 -05003571bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003572 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003573
3574 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003575 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3576 if (present_regions) {
3577 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003578 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003579 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3580 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003581 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3582 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3583 "extension swapchainCount is %i. These values must be equal.",
3584 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003585 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003586 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003587 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3588 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003589 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3590 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3591 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003592 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003593 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003594 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003595 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003596 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003597 }
3598 }
3599
3600 return skip;
3601}
3602
3603#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003604bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3605 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3606 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003607 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003608 bool skip = false;
3609
3610 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003611 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3612 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003613 }
3614
3615 return skip;
3616}
3617#endif // VK_USE_PLATFORM_WIN32_KHR
3618
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003619bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003620 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003621 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003622 bool skip = false;
3623
3624 if (pCreateInfo) {
3625 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3627 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003628 }
3629
3630 if (pCreateInfo->pPoolSizes) {
3631 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3632 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003633 skip |= LogError(
3634 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003635 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003636 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003637 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3638 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003639 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3640 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3641 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3642 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3643 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003644 }
Petr Krausc8655be2017-09-27 18:56:51 +02003645 }
3646 }
3647 }
3648
3649 return skip;
3650}
3651
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003652bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003653 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003654 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003655
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003656 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003657 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003658 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3659 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3660 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003661 }
3662
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003663 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003664 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003665 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3666 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3667 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003668 }
3669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003670 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003671 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3673 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3674 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003675 }
3676
3677 return skip;
3678}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003679
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003680bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003681 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003682 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003683
3684 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3686 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003687 }
3688 return skip;
3689}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003690
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003691bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3692 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003693 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003694 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003695
3696 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003697 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003698 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003699 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3700 "vkCmdDispatch(): baseGroupX (%" PRIu32
3701 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3702 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003703 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003704 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3705 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3706 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3707 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003708 }
3709
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003710 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003711 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003712 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3713 "vkCmdDispatch(): baseGroupY (%" PRIu32
3714 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3715 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003716 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3718 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3719 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3720 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003721 }
3722
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003723 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003724 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003725 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3726 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3727 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3728 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003729 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003730 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3731 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3732 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3733 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003734 }
3735
3736 return skip;
3737}
3738
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003739bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3740 VkPipelineBindPoint pipelineBindPoint,
3741 VkPipelineLayout layout, uint32_t set,
3742 uint32_t descriptorWriteCount,
3743 const VkWriteDescriptorSet *pDescriptorWrites) const {
3744 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3745}
3746
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003747bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3748 uint32_t firstExclusiveScissor,
3749 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003750 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003751 bool skip = false;
3752
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003753 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003754 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003755 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3757 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3758 ") is not 0.",
3759 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003760 }
3761 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003762 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3764 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3765 ") is not 1.",
3766 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003767 }
3768 } else { // multiViewport enabled
3769 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003770 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3772 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3773 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3774 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003775 }
3776 }
3777
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003778 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003779 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3780 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3781 ") must be less than maxViewports (=%" PRIu32 ").",
3782 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003783 }
3784
3785 if (pExclusiveScissors) {
3786 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3787 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3788
3789 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003790 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3791 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3792 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003793 }
3794
3795 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003796 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3797 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3798 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003799 }
3800
3801 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3802 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003803 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3804 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3805 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3806 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003807 }
3808
3809 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3810 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3812 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3813 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3814 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003815 }
3816 }
3817 }
3818
3819 return skip;
3820}
3821
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003822bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3823 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003824 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003825 bool skip = false;
3826 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003827 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3828 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3829 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003830 } else {
3831 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3832 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003833 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3834 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3835 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3836 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003837 }
3838 }
3839
3840 return skip;
3841}
3842
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003843bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3844 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003845 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003846 bool skip = false;
3847
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003848 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003849 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003850 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003851 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3852 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3853 ") is not 0.",
3854 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003855 }
3856 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003857 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003858 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3859 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3860 ") is not 1.",
3861 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003862 }
3863 }
3864
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003865 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003866 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3867 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3868 ") must be less than maxViewports (=%" PRIu32 ").",
3869 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003870 }
3871
3872 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003873 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003874 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3875 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3876 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3877 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003878 }
3879
3880 return skip;
3881}
3882
Jeff Bolz5c801d12019-10-09 10:38:45 -05003883bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3884 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3885 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003886 bool skip = false;
3887
Dave Houlton142c4cb2018-10-17 15:04:41 -06003888 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003889 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3890 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3891 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003892 }
3893
3894 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003895 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003896 }
3897
3898 return skip;
3899}
3900
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003901bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003902 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003903 bool skip = false;
3904
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003905 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003906 skip |= LogError(
3907 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003908 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3909 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003910 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003911 }
3912
3913 return skip;
3914}
3915
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003916bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3917 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003918 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003919 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003920 static const int condition_multiples = 0b0011;
3921 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003922 skip |= LogError(
3923 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003924 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003925 }
Lockee1c22882019-06-10 16:02:54 -06003926 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003927 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3928 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3929 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3930 stride);
Lockee1c22882019-06-10 16:02:54 -06003931 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003932 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003933 skip |= LogError(
3934 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3935 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003936 }
3937
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003938 return skip;
3939}
3940
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003941bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3942 VkDeviceSize offset, VkBuffer countBuffer,
3943 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003944 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003945 bool skip = false;
3946
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003947 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003948 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3949 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3950 "), is not a multiple of 4.",
3951 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003952 }
3953
3954 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003955 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3956 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3957 "), is not a multiple of 4.",
3958 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003959 }
3960
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003961 return skip;
3962}
3963
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003964bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003965 const VkAllocationCallbacks *pAllocator,
3966 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003967 bool skip = false;
3968
3969 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3970 if (pCreateInfo != nullptr) {
3971 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3972 // VkQueryPipelineStatisticFlagBits values
3973 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3974 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003975 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3976 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3977 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3978 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003979 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003980 if (pCreateInfo->queryCount == 0) {
3981 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3982 "vkCreateQueryPool(): queryCount must be greater than zero.");
3983 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003984 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003985 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003986}
3987
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003988bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3989 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003990 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003991 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3992 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003993}
3994
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003995void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003996 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3997 VkResult result) {
3998 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003999 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004000}
4001
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004002void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004003 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4004 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004005 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004006 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004007 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004008}
4009
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004010void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4011 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004012 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004013 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004014 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004015}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004016
4017bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004018 const VkAllocationCallbacks *pAllocator,
4019 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004020 bool skip = false;
4021
4022 if (pAllocateInfo) {
4023 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4024 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004025 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4026 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004027 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004028
4029 VkMemoryAllocateFlags flags = 0;
4030 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4031 if (flags_info) {
4032 flags = flags_info->flags;
4033 }
4034
4035 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4036 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4037 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004038 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4039 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4040 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004041 }
4042
4043#ifdef VK_USE_PLATFORM_WIN32_KHR
4044 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4045#endif
4046 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4047 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4048#ifdef VK_USE_PLATFORM_ANDROID_KHR
4049 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4050#endif
4051
4052 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004053 skip |= LogError(
4054 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004055 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4056 }
4057 if (
4058#ifdef VK_USE_PLATFORM_WIN32_KHR
4059 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4060#endif
4061 (import_memory_fd && import_memory_fd->handleType) ||
4062#ifdef VK_USE_PLATFORM_ANDROID_KHR
4063 (import_memory_ahb && import_memory_ahb->buffer) ||
4064#endif
4065 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004066 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4067 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004068 }
4069 }
4070
4071 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004072 VkBool32 capture_replay = false;
4073 VkBool32 buffer_device_address = false;
4074 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4075 if (vulkan_12_features) {
4076 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4077 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4078 } else {
4079 const auto *bda_features =
4080 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4081 if (bda_features) {
4082 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4083 buffer_device_address = bda_features->bufferDeviceAddress;
4084 }
4085 }
4086 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004087 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4088 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4089 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004090 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004091 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004092 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4093 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004094 }
4095 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004096 }
4097 return skip;
4098}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004099
Jason Macnak192fa0e2019-07-26 15:07:16 -07004100bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004101 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004102 bool skip = false;
4103
4104 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4105 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4106 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004107 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004108 } else {
4109 uint32_t vertex_component_size = 0;
4110 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4111 vertex_component_size = 4;
4112 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4113 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4114 vertex_component_size = 2;
4115 }
4116 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004117 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004118 }
4119 }
4120
4121 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4122 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004123 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004124 } else {
4125 uint32_t index_element_size = 0;
4126 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4127 index_element_size = 4;
4128 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4129 index_element_size = 2;
4130 }
4131 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004132 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004133 }
4134 }
4135 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4136 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004137 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004138 }
4139 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004140 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004141 }
4142 }
4143
4144 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004145 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004146 }
4147
4148 return skip;
4149}
4150
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004151bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4152 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004153 bool skip = false;
4154
4155 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004156 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004157 }
4158 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004159 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004160 }
4161
4162 return skip;
4163}
4164
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004165bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4166 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004167 bool skip = false;
4168 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004169 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004170 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004171 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004172 }
4173 return skip;
4174}
4175
4176bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004177 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004178 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004179 bool skip = false;
4180 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004181 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4182 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4183 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004184 }
4185 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004186 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4187 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4188 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004189 }
4190 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4191 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004192 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4193 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4194 "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 -07004195 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004196 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004197 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004198 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4199 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004200 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4201 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004202 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004203 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004204 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4205 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4206 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004207 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004208 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004209 uint64_t total_triangle_count = 0;
4210 for (uint32_t i = 0; i < info.geometryCount; i++) {
4211 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004212
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004213 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004214
Jason Macnak5c954952019-07-09 15:46:12 -07004215 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4216 continue;
4217 }
4218 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4219 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004220 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004221 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4222 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4223 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004224 }
4225 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004226 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4227 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4228 for (uint32_t i = 1; i < info.geometryCount; i++) {
4229 const VkGeometryNV &geometry = info.pGeometries[i];
4230 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004231 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004232 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4233 "info.pGeometries[0].geometryType.",
4234 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004235 }
4236 }
4237 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004238 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4239 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4240 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4241 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4242 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4243 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4244 }
4245 }
4246 skip |=
4247 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004248 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004249 return skip;
4250}
4251
Ricardo Garciaa4935972019-02-21 17:43:18 +01004252bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4253 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004254 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004255 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004256 if (pCreateInfo) {
4257 if ((pCreateInfo->compactedSize != 0) &&
4258 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004259 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4260 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4261 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4262 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004263 }
Jason Macnak5c954952019-07-09 15:46:12 -07004264
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004265 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004266 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004267 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004268 return skip;
4269}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004270
Jeff Bolz5c801d12019-10-09 10:38:45 -05004271bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4272 const VkAccelerationStructureInfoNV *pInfo,
4273 VkBuffer instanceData, VkDeviceSize instanceOffset,
4274 VkBool32 update, VkAccelerationStructureNV dst,
4275 VkAccelerationStructureNV src, VkBuffer scratch,
4276 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004277 bool skip = false;
4278
4279 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004280 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004281 }
4282
4283 return skip;
4284}
4285
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004286bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4287 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4288 VkAccelerationStructureKHR *pAccelerationStructure) const {
4289 bool skip = false;
4290
4291 if (pCreateInfo) {
4292 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4293 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4294 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4295 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4296 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4297 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4298 i);
4299 }
4300 }
4301
4302 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4303 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4304 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4305 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4306 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4307 i);
4308 }
4309 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004310 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4311 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4312 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4313 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4314 skip |= LogError(
4315 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4316 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4317 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4318 }
4319 }
4320 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4321 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4322 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4323 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4324 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4325 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4326 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4327 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4328 }
4329 }
4330 }
4331
4332 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4333 pCreateInfo->maxGeometryCount != 1) {
4334 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4335 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4336 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004337 }
sourav parmard1521802020-06-07 21:49:02 -07004338 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4339 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4340 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4341 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4342 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004343
4344 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4345 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4346 skip |= LogError(
4347 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4348 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4349 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4350 }
4351
4352 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4353 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4354 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4355 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4356 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4357 }
4358
4359 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4360 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4361 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4362 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4363 if (geometry_type != first_geometry_type) {
4364 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4365 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4366 "pGeometryInfos[0].geometryType.",
4367 i);
4368 }
4369 }
4370 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004371 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4372 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4373 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4374 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4375 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4376 "maxGeometryCount %d.",
4377 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4378 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004379 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004380 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4381 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4382 if (pCreateInfo->deviceAddress != 0) {
4383 skip |=
4384 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4385 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4386 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4387 }
4388 }
sourav parmar83c31b12020-05-06 12:30:54 -07004389 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4390 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4391 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4392 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004393 return skip;
4394}
4395
Jason Macnak5c954952019-07-09 15:46:12 -07004396bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4397 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004398 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004399 bool skip = false;
4400 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004401 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4402 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004403 }
4404 return skip;
4405}
4406
Peter Chen85366392019-05-14 15:20:11 -04004407bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4408 uint32_t createInfoCount,
4409 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4410 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004411 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004412 bool skip = false;
4413
4414 for (uint32_t i = 0; i < createInfoCount; i++) {
4415 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4416 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004417 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004418 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4419 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4420 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4421 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004422 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004423
4424 const auto *pipeline_cache_contol_features =
4425 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4426 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4427 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4428 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4429 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4430 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4431 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4432 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4433 }
4434 }
4435
sourav parmarf4a78252020-04-10 13:04:21 -07004436 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4437 skip |=
4438 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4439 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4440 }
4441 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4442 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4443 skip |=
4444 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4445 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4446 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4447 }
4448 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4449 if (pCreateInfos[i].basePipelineIndex != -1) {
4450 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4451 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4452 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4453 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4454 "and pCreateInfos->basePipelineIndex is not -1.");
4455 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004456 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4457 skip |=
4458 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4459 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4460 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4461 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4462 "that element.");
4463 }
sourav parmarf4a78252020-04-10 13:04:21 -07004464 }
4465 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4466 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4467 skip |=
4468 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4469 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4470 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4471 "commands pCreateInfos parameter.");
4472 }
4473 } else {
4474 if (pCreateInfos[i].basePipelineIndex != -1) {
4475 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4476 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4477 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4478 }
4479 }
4480 }
4481 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4482 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4483 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4484 }
4485 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4486 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4487 "vkCreateRayTracingPipelinesNV: flags must not include "
4488 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4489 }
4490 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4491 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4492 "vkCreateRayTracingPipelinesNV: flags must not include "
4493 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4494 }
4495 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4496 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4497 "vkCreateRayTracingPipelinesNV: flags must not include "
4498 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4499 }
4500 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4501 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4502 "vkCreateRayTracingPipelinesNV: flags must not include "
4503 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4504 }
4505 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4506 skip |= LogError(
4507 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4508 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4509 }
4510 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4511 skip |= LogError(
4512 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4513 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4514 }
Peter Chen85366392019-05-14 15:20:11 -04004515 }
4516
4517 return skip;
4518}
4519
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004520bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4521 uint32_t createInfoCount,
4522 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4523 const VkAllocationCallbacks *pAllocator,
4524 VkPipeline *pPipelines) const {
4525 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004526 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4527 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4528 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4529 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4530 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004531 for (uint32_t i = 0; i < createInfoCount; i++) {
4532 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4533 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4534 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4535 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4536 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4537 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4538 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4539 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004540 const auto *pipeline_cache_contol_features =
4541 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4542 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4543 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4544 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4545 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4546 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4547 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4548 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4549 }
4550 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004551 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4552 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4553 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4554 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4555 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4556 }
4557 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4558 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4559 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4560 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4561 }
4562 }
4563
sourav parmarf4a78252020-04-10 13:04:21 -07004564 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4565 skip |=
4566 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4567 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4568 }
4569 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4570 if (pCreateInfos[i].pLibraryInterface == NULL)
4571 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4572 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4573 }
4574 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4575 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4576 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4577 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4578 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4579 skip |= LogError(
4580 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4581 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4582 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4583 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4584 "must not be VK_SHADER_UNUSED_KHR");
4585 }
4586 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4587 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4588 skip |= LogError(
4589 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4590 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4591 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4592 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4593 "element must not be VK_SHADER_UNUSED_KHR");
4594 }
4595 }
4596 }
4597 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4598 if (pCreateInfos[i].basePipelineIndex != -1) {
4599 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4600 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4601 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4602 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4603 "and pCreateInfos->basePipelineIndex is not -1.");
4604 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004605 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4606 skip |=
4607 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4608 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4609 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4610 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4611 "element.");
4612 }
sourav parmarf4a78252020-04-10 13:04:21 -07004613 }
4614 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4615 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4616 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4617 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4618 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4619 "commands pCreateInfos parameter %d.",
4620 pCreateInfos[i].basePipelineIndex, createInfoCount);
4621 }
4622 } else {
4623 if (pCreateInfos[i].basePipelineIndex != -1) {
4624 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4625 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4626 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4627 }
4628 }
4629 }
4630 if (pCreateInfos[i].libraries.libraryCount == 0) {
4631 if (pCreateInfos[i].stageCount == 0) {
4632 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4633 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4634 }
4635 if (pCreateInfos[i].groupCount == 0) {
4636 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4637 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4638 }
4639 } else {
4640 if (pCreateInfos[i].pLibraryInterface == NULL) {
4641 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4642 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4643 }
4644 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004645 }
4646
4647 return skip;
4648}
4649
Mike Schuchardt21638df2019-03-16 10:52:02 -07004650#ifdef VK_USE_PLATFORM_WIN32_KHR
4651bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4652 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004653 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004654 bool skip = false;
4655 if (!device_extensions.vk_khr_swapchain)
4656 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4657 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4658 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4659 if (!device_extensions.vk_khr_surface)
4660 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4661 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4662 skip |=
4663 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4664 if (!device_extensions.vk_ext_full_screen_exclusive)
4665 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4666 skip |= validate_struct_type(
4667 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4668 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4669 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4670 if (pSurfaceInfo != NULL) {
4671 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4672 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4673 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4674
4675 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4676 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4677 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4678 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004679 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4680 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004681
4682 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4683 }
4684 return skip;
4685}
4686#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004687
4688bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4689 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004690 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004691 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4692 bool skip = false;
4693 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4694 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4695 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4696 }
4697 return skip;
4698}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004699
4700bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004701 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004702 bool skip = false;
4703
4704 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004705 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4706 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004707 }
4708
4709 return skip;
4710}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004711
4712bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004713 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004714 bool skip = false;
4715
4716 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004717 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4718 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004719 }
4720
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004721 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004722 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004723 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4724 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004725 }
4726
4727 return skip;
4728}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004729
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004730bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4731 uint32_t bindingCount, const VkBuffer *pBuffers,
4732 const VkDeviceSize *pOffsets) const {
4733 bool skip = false;
4734 if (firstBinding > device_limits.maxVertexInputBindings) {
4735 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4736 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4737 device_limits.maxVertexInputBindings);
4738 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4739 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4740 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4741 "maxVertexInputBindings (%u)",
4742 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4743 }
4744
Jeff Bolz165818a2020-05-08 11:19:03 -05004745 for (uint32_t i = 0; i < bindingCount; ++i) {
4746 if (pBuffers[i] == VK_NULL_HANDLE) {
4747 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4748 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4749 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4750 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4751 } else {
4752 if (pOffsets[i] != 0) {
4753 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4754 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4755 }
4756 }
4757 }
4758 }
4759
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004760 return skip;
4761}
4762
Mark Lobodzinski84988402019-09-11 15:27:30 -06004763bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004764 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004765 bool skip = false;
4766 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004767 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4768 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004769 }
4770 return skip;
4771}
4772
4773bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004774 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004775 bool skip = false;
4776 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004777 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4778 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004779 }
4780 return skip;
4781}
Petr Kraus3d720392019-11-13 02:52:39 +01004782
4783bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4784 VkSemaphore semaphore, VkFence fence,
4785 uint32_t *pImageIndex) const {
4786 bool skip = false;
4787
4788 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004789 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4790 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004791 }
4792
4793 return skip;
4794}
4795
4796bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4797 uint32_t *pImageIndex) const {
4798 bool skip = false;
4799
4800 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004801 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4802 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004803 }
4804
4805 return skip;
4806}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004807
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004808bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4809 uint32_t firstBinding, uint32_t bindingCount,
4810 const VkBuffer *pBuffers,
4811 const VkDeviceSize *pOffsets,
4812 const VkDeviceSize *pSizes) const {
4813 bool skip = false;
4814
4815 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4816 for (uint32_t i = 0; i < bindingCount; ++i) {
4817 if (pOffsets[i] & 3) {
4818 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4819 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4820 }
4821 }
4822
4823 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4824 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4825 "%s: The firstBinding(%" PRIu32
4826 ") index is greater than or equal to "
4827 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4828 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4829 }
4830
4831 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4832 skip |=
4833 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4834 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4835 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4836 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4837 }
4838
4839 for (uint32_t i = 0; i < bindingCount; ++i) {
4840 // pSizes is optional and may be nullptr.
4841 if (pSizes != nullptr) {
4842 if (pSizes[i] != VK_WHOLE_SIZE &&
4843 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4844 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4845 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4846 ") is not VK_WHOLE_SIZE and is greater than "
4847 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4848 cmd_name, i, pSizes[i]);
4849 }
4850 }
4851 }
4852
4853 return skip;
4854}
4855
4856bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4857 uint32_t firstCounterBuffer,
4858 uint32_t counterBufferCount,
4859 const VkBuffer *pCounterBuffers,
4860 const VkDeviceSize *pCounterBufferOffsets) const {
4861 bool skip = false;
4862
4863 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4864 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4865 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4866 "%s: The firstCounterBuffer(%" PRIu32
4867 ") index is greater than or equal to "
4868 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4869 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4870 }
4871
4872 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4873 skip |=
4874 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4875 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4876 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4877 cmd_name, firstCounterBuffer, counterBufferCount,
4878 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4879 }
4880
4881 return skip;
4882}
4883
4884bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4885 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4886 const VkBuffer *pCounterBuffers,
4887 const VkDeviceSize *pCounterBufferOffsets) const {
4888 bool skip = false;
4889
4890 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4891 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4892 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4893 "%s: The firstCounterBuffer(%" PRIu32
4894 ") index is greater than or equal to "
4895 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4896 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4897 }
4898
4899 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4900 skip |=
4901 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4902 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4903 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4904 cmd_name, firstCounterBuffer, counterBufferCount,
4905 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4906 }
4907
4908 return skip;
4909}
4910
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004911bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4912 uint32_t firstInstance, VkBuffer counterBuffer,
4913 VkDeviceSize counterBufferOffset,
4914 uint32_t counterOffset, uint32_t vertexStride) const {
4915 bool skip = false;
4916
4917 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004918 skip |= LogError(
4919 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004920 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4921 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4922 }
4923
4924 return skip;
4925}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004926
4927bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4928 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4929 const VkAllocationCallbacks *pAllocator,
4930 VkSamplerYcbcrConversion *pYcbcrConversion,
4931 const char *apiName) const {
4932 bool skip = false;
4933
4934 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004935 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004936 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02004937 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
4938 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
4939 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4940 "samplerYcbcrConversion must be enabled to call %s.", apiName);
4941 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004942 }
4943 return skip;
4944}
4945
4946bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4947 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4948 const VkAllocationCallbacks *pAllocator,
4949 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4950 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4951 "vkCreateSamplerYcbcrConversion");
4952}
4953
4954bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4955 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4956 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4957 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4958 "vkCreateSamplerYcbcrConversionKHR");
4959}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004960
4961bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4962 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4963 bool skip = false;
4964 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4965 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4966
4967 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004968 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4969 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4970 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4971 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4972 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004973 }
4974 return skip;
4975}
sourav parmara96ab1a2020-04-25 16:28:23 -07004976
4977bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4978 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4979 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004980 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4981 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4982 skip |=
4983 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4984 "vkCopyAccelerationStructureToMemoryKHR: the "
4985 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4986 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004987 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4988 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4989 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4990 }
4991 return skip;
4992}
4993
4994bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4995 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4996 bool skip = false;
4997 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4998 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4999 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5000 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5001 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005002 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5003 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005004 skip |= LogError(
5005 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5006 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5007 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5008 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005009 return skip;
5010}
5011
5012bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5013 const char *api_name) const {
5014 bool skip = false;
5015 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5016 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5017 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5018 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5019 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5020 api_name);
5021 }
5022 return skip;
5023}
5024
5025bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5026 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5027 bool skip = false;
5028 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005029 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5030 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5031 skip |= LogError(
5032 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5033 "vkCopyAccelerationStructureKHR(): the "
5034 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5035 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005036 return skip;
5037}
5038
5039bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5040 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5041 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005042 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5043 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005044 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5045 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5046 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5047 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005048 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5049 return skip;
5050}
5051
5052bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005053 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005054 bool skip = false;
5055 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005056 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005057 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005058 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005059 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5060 }
5061 return skip;
5062}
5063
5064bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5065 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5066 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005067 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5068 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5069 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5070 skip |=
5071 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5072 "vkCopyMemoryToAccelerationStructureKHR() :the "
5073 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5074 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005075 return skip;
5076}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005077
sourav parmara96ab1a2020-04-25 16:28:23 -07005078bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5079 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5080 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005081 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5082 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005083 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5084 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5085 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5086 }
sourav parmar83c31b12020-05-06 12:30:54 -07005087 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5088 return skip;
5089}
5090bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5091 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5092 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5093 bool skip = false;
5094 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5095 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5096 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5097 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5098 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5099 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5100 }
5101 return skip;
5102}
5103bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5104 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5105 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5106 bool skip = false;
5107 if (dataSize < accelerationStructureCount * stride) {
5108 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5109 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5110 "accelerationStructureCount (%d) *stride(%zu).",
5111 dataSize, accelerationStructureCount, stride);
5112 }
5113 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5114 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5115 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5116 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5117 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5118 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5119 }
5120 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5121 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5122 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5123 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5124 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5125 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5126 stride);
5127 }
5128 }
5129 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5130 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5131 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5132 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5133 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5134 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5135 stride);
5136 }
5137 }
5138 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5139 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5140 skip |=
5141 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5142 "vkWriteAccelerationStructuresPropertiesKHR: the "
5143 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5144 "feature must be enabled ");
5145 }
5146 return skip;
5147}
5148bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5149 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5150 bool skip = false;
5151 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5152 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5153 skip |= LogError(device,
5154 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5155 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5156 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5157 "must be enabled to call this function.");
5158 }
5159 return skip;
5160}
5161
5162bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5163 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5164 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5165 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5166 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5167 uint32_t width, uint32_t height, uint32_t depth) const {
5168 bool skip = false;
5169 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5170 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5171 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5172 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5173 }
5174 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5175 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5176 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5177 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5178 }
5179 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5180 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5181 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5182 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5183 }
5184 // hitShader
5185 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5186 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5187 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5188 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5189 }
5190 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5191 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5192 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5193 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5194 }
5195 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5196 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5197 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5198 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5199 }
5200
5201 // missShader
5202 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5203 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5204 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5205 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5206 }
5207 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5208 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5209 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5210 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5211 }
5212 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5213 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5214 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5215 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5216 }
5217
5218 // raygenShader
5219 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5220 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5221 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5222 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5223 }
5224 return skip;
5225}
5226
5227bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5228 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5229 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5230 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5231 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5232 VkBuffer buffer, VkDeviceSize offset) const {
5233 bool skip = false;
5234 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5235 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5236 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5237 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5238 "feature must be enabled.");
5239 }
5240 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5241 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5242 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5243 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5244 }
5245 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5246 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5247 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5248 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5249 }
5250 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5251 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5252 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5253 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5254 }
5255 // hitShader
5256 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5257 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5258 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5259 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5260 }
5261 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5262 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5263 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5264 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5265 }
5266 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5267 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5268 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5269 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5270 }
5271
5272 // missShader
5273 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5274 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5275 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5276 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5277 }
5278 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5279 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5280 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5281 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5282 }
5283 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5284 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5285 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5286 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5287 }
5288
5289 // raygenShader
5290 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5291 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5292 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5293 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5294 }
5295 return skip;
5296}
5297bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5298 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5299 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5300 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5301 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5302 uint32_t width, uint32_t height, uint32_t depth) const {
5303 bool skip = false;
5304 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5305 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5306 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5307 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5308 }
5309 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5310 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5311 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5312 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5313 }
5314 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5315 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5316 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5317 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5318 }
5319
5320 // hitShader
5321 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5322 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5323 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5324 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5325 }
5326 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5327 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5328 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5329 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5330 }
5331 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5332 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5333 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5334 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5335 }
5336
5337 // missShader
5338 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5339 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5340 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5341 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5342 }
5343 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5344 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5345 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5346 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5347 }
5348 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5349 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5350 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5351 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5352 }
5353
5354 // raygenShader
5355 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5356 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5357 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005358 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5359 }
5360 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5361 skip |=
5362 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5363 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5364 }
5365 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5366 skip |=
5367 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5368 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5369 }
5370 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5371 skip |=
5372 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5373 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005374 }
5375 return skip;
5376}
5377
5378bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5379 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5380 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5381 bool skip = false;
5382 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5383 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5384 skip |= LogError(
5385 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5386 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5387 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5388 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005389 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5390 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005391 skip |=
5392 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5393 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5394 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5395 }
5396 return false;
5397}
5398
5399bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5400 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5401 bool skip = false;
5402 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5403 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5404 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5405 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5406 }
5407 return skip;
5408}
5409
5410bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5411 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5412 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5413 bool skip = false;
5414 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5415 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005416 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5417 "vkBuildAccelerationStructureKHR: The "
5418 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5419 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005420 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005421 return skip;
5422}
sourav parmara24fb7b2020-05-26 10:50:04 -07005423bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5424 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5425 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5426 bool skip = false;
5427 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005428 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5429 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005430 skip |=
5431 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5432 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5433 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5434 }
5435 }
5436 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005437}