blob: 93bfe49acfd412db6bd870ca92fcf1bdcda7249c [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
sfricke-samsungfd76c342020-05-29 23:13:43 -0700489 // feature dependencies for VK_KHR_multiview
490 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
491 VkBool32 multiview = VK_FALSE;
492 VkBool32 multiviewGeometryShader = VK_FALSE;
493 VkBool32 multiviewTessellationShader = VK_FALSE;
494 if (vulkan_11_features) {
495 multiview = vulkan_11_features->multiview;
496 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
497 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
498 } else if (multiview_features) {
499 multiview = multiview_features->multiview;
500 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
501 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
502 }
503 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
504 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
505 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
506 }
507 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
508 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
509 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
510 }
511
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600512 return skip;
513}
514
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500515bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700516 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700517 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
518 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
519 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700522 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523}
524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700525bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500526 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100527 bool skip = false;
528
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 skip |=
531 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532
533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
534 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
535 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
536 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
538 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
542 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
543 // queueFamilyIndexCount uint32_t values
544 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
546 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
548 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700552 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
553 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
554 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
555 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
556 }
557
558 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
559 skip |=
560 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
561 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
562 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
563 }
564
565 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
566 skip |=
567 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
568 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
569 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
570 }
571
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600572 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
573 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
574 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
575 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
577 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
578 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600579 }
580 }
581
582 return skip;
583}
584
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700585bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500586 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600587 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600588
589 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600590 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
591 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
592 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
593 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
595 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
596 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600597 }
598
599 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
600 // queueFamilyIndexCount uint32_t values
601 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
603 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
604 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
605 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600606 }
607 }
608
Dave Houlton413a6782018-05-22 13:01:54 -0600609 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700610 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600611 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700612 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600613 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600615
Dave Houlton413a6782018-05-22 13:01:54 -0600616 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700617 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600618 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700619 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600620
Dave Houlton130c0212018-01-29 13:39:56 -0700621 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700622 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
623 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700624 skip |= LogError(
625 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600626 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
627 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700628 }
629
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600630 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100631 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
632 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700633 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
634 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
635 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600636 }
637
638 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100639 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
640 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700641 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
642 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
643 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
644 ") are not equal.",
645 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100646 }
647
648 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700649 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
650 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
651 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
652 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100653 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600654 }
655
656 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700657 skip |= LogError(
658 device, "VUID-VkImageCreateInfo-imageType-00957",
659 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 }
661 }
662
Dave Houlton130c0212018-01-29 13:39:56 -0700663 // 3D image may have only 1 layer
664 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700665 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
666 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700667 }
668
669 // If multi-sample, validate type, usage, tiling and mip levels.
670 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
671 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600672 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700673 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
674 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700675 }
676
677 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
678 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
679 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
680 // At least one of the legal attachment bits must be set
681 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700682 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
683 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700684 }
685 // No flags other than the legal attachment bits may be set
686 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
687 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700688 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
689 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700690 }
691 }
692
Jeff Bolzef40fec2018-09-01 22:04:34 -0500693 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600694 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500695 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600696 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
697 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500698 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600699 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
701 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
702 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 }
704
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600705 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700706 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
707 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
708 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600709 }
710
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700711 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700712 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
713 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
714 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100715 }
716
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700717 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
718 skip |= LogError(
719 device, "VUID-VkImageCreateInfo-flags-01924",
720 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
721 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
722 }
723
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600724 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
725 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
726 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
727 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
729 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
730 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600731 }
732
733 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
734 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
735 // Linear tiling is unsupported
736 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700737 skip |= LogError(device, kVUID_PVError_InvalidUsage,
738 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
739 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600740 }
741
742 // Sparse 1D image isn't valid
743 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
745 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600746 }
747
748 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700749 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
751 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
752 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 }
754
755 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700756 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700757 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
758 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
759 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600760 }
761
762 // Multi-sample 2D image when device doesn't support it
763 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700764 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600765 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700766 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
767 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
768 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700769 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600770 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700771 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
772 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
773 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700774 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600775 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700776 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
777 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
778 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700779 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600780 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
782 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
783 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600784 }
785 }
786 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500787
Jeff Bolz9af91c52018-09-01 21:53:57 -0500788 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
789 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700790 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
791 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
792 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500793 }
794 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
796 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
797 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500798 }
799 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
801 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
802 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500803 }
804 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500805
806 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600807 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700808 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
809 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
810 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500811 }
812
Dave Houlton142c4cb2018-10-17 15:04:41 -0600813 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
815 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
816 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
817 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500818 }
819
Dave Houlton142c4cb2018-10-17 15:04:41 -0600820 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
822 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
823 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
824 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500825 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600826 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700827 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
828 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
829 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
830 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500831 }
832 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500833
sfricke-samsung8f658d42020-05-03 20:12:24 -0700834 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
835 (FormatHasDepth(pCreateInfo->format) == false)) {
836 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
837 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
838 "format must be a depth or depth/stencil format.");
839 }
840
Andrew Fobel3abeb992020-01-20 16:33:22 -0500841 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
842 if (image_stencil_struct != nullptr) {
843 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
844 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
845 // No flags other than the legal attachment bits may be set
846 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
847 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700848 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
849 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
850 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
851 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500852 }
853 }
854
855 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
856 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
857 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
858 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
860 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
861 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
862 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500863 }
864
865 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
866 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700867 LogError(device, "VUID-VkImageCreateInfo-format-02537",
868 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
869 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
870 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500871 }
872 }
873
874 if (!physical_device_features.shaderStorageImageMultisample &&
875 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
876 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
877 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700878 LogError(device, "VUID-VkImageCreateInfo-format-02538",
879 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
880 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
881 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500882 }
883
884 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
885 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700886 skip |= LogError(
887 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500888 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
889 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
890 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
891 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
892 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 skip |= LogError(
894 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500895 "vkCreateImage(): Depth-stencil image in which usage does not include "
896 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
897 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
898 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
899 }
900
901 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
902 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700903 skip |= LogError(
904 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500905 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
906 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
907 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
908 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
909 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700910 skip |= LogError(
911 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500912 "vkCreateImage(): Depth-stencil image in which usage does not include "
913 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
914 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
915 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
916 }
917 }
918 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700919
920 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
921 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
922 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
923 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
924 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
925 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700926
927 if (device_extensions.vk_ext_image_drm_format_modifier) {
928 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
929 const auto drm_format_mod_explict =
930 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
931 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
932 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
933 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
934 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
935 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
936 "either VkImageDrmFormatModifierListCreateInfoEXT or "
937 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
938 }
939 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
940 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
941 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
942 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
943 "in the pNext chain");
944 }
945 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200946
947 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
948 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
950 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
951 "imageType must be VK_IMAGE_TYPE_2D.");
952 }
953 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
955 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
956 "samples must be VK_SAMPLE_COUNT_1_BIT.");
957 }
958 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
959 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
960 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
961 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
962 }
963 }
964 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
965 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
966 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
967 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
968 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
969 }
970 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
971 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
972 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
973 "imageType must be VK_IMAGE_TYPE_2D.");
974 }
975 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
976 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
977 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
978 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
979 }
980 if (pCreateInfo->mipLevels != 1) {
981 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
982 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
983 pCreateInfo->mipLevels);
984 }
985 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -0700986
987 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
988 if (swapchain_create_info != nullptr) {
989 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
990 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
991 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
992 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
993 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
994 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
995
996 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
997 // also implicitly forces the check above that extent.depth is 1
998 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
999 string_VkImageType(pCreateInfo->imageType));
1000 }
1001 if (pCreateInfo->mipLevels != 1) {
1002 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1003 pCreateInfo->mipLevels);
1004 }
1005 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1006 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1007 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1008 }
1009 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1010 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1011 base_message, string_VkImageTiling(pCreateInfo->tiling));
1012 }
1013 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1014 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1015 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1016 }
1017 const VkImageCreateFlags valid_flags =
1018 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1019 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1020 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1021 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1022 pCreateInfo->flags);
1023 }
1024 }
1025 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001026 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001027
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001028 return skip;
1029}
1030
Jeff Bolz99e3f632020-03-24 22:59:22 -05001031bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1032 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1033 bool skip = false;
1034
1035 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001036 // Validate feature set if using CUBE_ARRAY
1037 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1038 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1039 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1040 "enabling the imageCubeArray feature.");
1041 }
1042
Jeff Bolz99e3f632020-03-24 22:59:22 -05001043 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1044 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1045 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001046 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001047 pCreateInfo->subresourceRange.layerCount);
1048 }
1049 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001050 skip |= LogError(
1051 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1052 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1053 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001054 }
1055 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001056
1057 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1058 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1059 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1060 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1061 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1062 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1063 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1064 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1065 }
1066 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1067 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1068 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1069 "not an ASTC format.",
1070 string_VkFormat(pCreateInfo->format));
1071 }
1072 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001073
1074 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1075 if (ycbcr_conversion != nullptr) {
1076 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1077 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1078 skip |= LogError(
1079 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1080 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1081 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1082 "r swizzle = %s\n"
1083 "g swizzle = %s\n"
1084 "b swizzle = %s\n"
1085 "a swizzle = %s\n",
1086 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1087 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1088 }
1089 }
1090 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001091 }
1092 return skip;
1093}
1094
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001095bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001096 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001097 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001098
1099 // Note: for numerical correctness
1100 // - float comparisons should expect NaN (comparison always false).
1101 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1102
1103 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001104 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001105 if (v1_f <= 0.0f) return true;
1106
1107 float intpart;
1108 const float fract = modff(v1_f, &intpart);
1109
1110 assert(std::numeric_limits<float>::radix == 2);
1111 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1112 if (intpart >= u32_max_plus1) return false;
1113
1114 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1115 if (v1_u32 < v2_u32)
1116 return true;
1117 else if (v1_u32 == v2_u32 && fract == 0.0f)
1118 return true;
1119 else
1120 return false;
1121 };
1122
1123 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1124 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1125 return (v1_f <= v2_f);
1126 };
1127
1128 // width
1129 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001130 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001131
1132 if (!(viewport.width > 0.0f)) {
1133 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001134 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1135 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001136 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1137 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001138 skip |= LogError(object, "VUID-VkViewport-width-01771",
1139 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1140 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001141 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001142 skip |= LogWarning(object, kVUID_PVError_NONE,
1143 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1144 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1145 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001146 }
1147
1148 // height
1149 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001150 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001151 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001152
1153 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1154 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001155 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1156 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001157 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1158 height_healthy = false;
1159
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001160 skip |= LogError(object, "VUID-VkViewport-height-01773",
1161 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1162 ").",
1163 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001164 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1165 height_healthy = false;
1166
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001167 skip |= LogWarning(
1168 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001169 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001170 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001171 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001172 }
1173
1174 // x
1175 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001176 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001177 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001178 skip |= LogError(object, "VUID-VkViewport-x-01774",
1179 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1180 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001181 }
1182
1183 // x + width
1184 if (x_healthy && width_healthy) {
1185 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001186 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001187 skip |= LogError(
1188 object, "VUID-VkViewport-x-01232",
1189 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1190 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1191 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001192 }
1193 }
1194
1195 // y
1196 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001197 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001198 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001199 skip |= LogError(object, "VUID-VkViewport-y-01775",
1200 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1201 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001202 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001203 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001204 skip |= LogError(object, "VUID-VkViewport-y-01776",
1205 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1206 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001207 }
1208
1209 // y + height
1210 if (y_healthy && height_healthy) {
1211 const float boundary = viewport.y + viewport.height;
1212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001213 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001214 skip |= LogError(object, "VUID-VkViewport-y-01233",
1215 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1216 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1217 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001218 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001219 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001220 LogError(object, "VUID-VkViewport-y-01777",
1221 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1222 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1223 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001224 }
1225 }
1226
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001227 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001228 // minDepth
1229 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001230 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001231
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001232 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1233 "[0.0, 1.0] range.",
1234 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001235 }
1236
1237 // maxDepth
1238 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001239 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001240
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001241 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1242 "[0.0, 1.0] range.",
1243 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001244 }
1245 }
1246
1247 return skip;
1248}
1249
Dave Houlton142c4cb2018-10-17 15:04:41 -06001250struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001251 VkShadingRatePaletteEntryNV shadingRate;
1252 uint32_t width;
1253 uint32_t height;
1254};
1255
1256// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001257static SampleOrderInfo sampleOrderInfos[] = {
1258 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1259 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1260 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1261 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1262 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1263 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001264};
1265
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001266bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001267 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001268
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001269 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001270 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001271 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001272 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001273 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001274 break;
1275 }
1276 }
1277
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001278 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001279 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1280 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1281 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001282 return skip;
1283 }
1284
Dave Houlton142c4cb2018-10-17 15:04:41 -06001285 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001286 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001287 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1288 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1289 ") must "
1290 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1291 "is set in framebufferNoAttachmentsSampleCounts.",
1292 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001293 }
1294
Jeff Bolz9af91c52018-09-01 21:53:57 -05001295 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001296 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1297 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1298 ") must "
1299 "be equal to the product of sampleCount (=%" PRIu32
1300 "), the fragment width for shadingRate "
1301 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1302 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001303 }
1304
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001305 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001306 skip |= LogError(
1307 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001308 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1309 ") must "
1310 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001311 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001312 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001313
1314 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001315 // the first width*height*sampleCount bits to all be set. Note: There is no
1316 // guarantee that 64 bits is enough, but practically it's unlikely for an
1317 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001318 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001319 uint64_t sampleLocationsMask = 0;
1320 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1321 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1322 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001323 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1324 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001325 }
1326 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001327 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1328 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001329 }
1330 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001331 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1332 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001333 }
1334 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1335 sampleLocationsMask |= 1ULL << idx;
1336 }
1337
1338 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1339 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001340 skip |= LogError(
1341 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001342 "The array pSampleLocations must contain exactly one entry for "
1343 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001344 }
1345
1346 return skip;
1347}
1348
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001349bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1350 uint32_t createInfoCount,
1351 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1352 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001353 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001354 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001355
1356 if (pCreateInfos != nullptr) {
1357 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001358 bool has_dynamic_viewport = false;
1359 bool has_dynamic_scissor = false;
1360 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001361 bool has_dynamic_depth_bias = false;
1362 bool has_dynamic_blend_constant = false;
1363 bool has_dynamic_depth_bounds = false;
1364 bool has_dynamic_stencil_compare = false;
1365 bool has_dynamic_stencil_write = false;
1366 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001367 bool has_dynamic_viewport_w_scaling_nv = false;
1368 bool has_dynamic_discard_rectangle_ext = false;
1369 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001370 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001371 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001372 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001373 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001374 if (pCreateInfos[i].pDynamicState != nullptr) {
1375 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1376 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1377 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001378 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1379 if (has_dynamic_viewport == true) {
1380 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1381 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1382 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1383 i);
1384 }
1385 has_dynamic_viewport = true;
1386 }
1387 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1388 if (has_dynamic_scissor == true) {
1389 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1390 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1391 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1392 i);
1393 }
1394 has_dynamic_scissor = true;
1395 }
1396 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1397 if (has_dynamic_line_width == true) {
1398 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1399 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1400 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1401 i);
1402 }
1403 has_dynamic_line_width = true;
1404 }
1405 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1406 if (has_dynamic_depth_bias == true) {
1407 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1408 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1409 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1410 i);
1411 }
1412 has_dynamic_depth_bias = true;
1413 }
1414 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1415 if (has_dynamic_blend_constant == true) {
1416 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1417 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1418 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1419 i);
1420 }
1421 has_dynamic_blend_constant = true;
1422 }
1423 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1424 if (has_dynamic_depth_bounds == true) {
1425 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1426 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1427 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1428 i);
1429 }
1430 has_dynamic_depth_bounds = true;
1431 }
1432 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1433 if (has_dynamic_stencil_compare == true) {
1434 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1435 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1436 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1437 i);
1438 }
1439 has_dynamic_stencil_compare = true;
1440 }
1441 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1442 if (has_dynamic_stencil_write == true) {
1443 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1444 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1445 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1446 i);
1447 }
1448 has_dynamic_stencil_write = true;
1449 }
1450 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1451 if (has_dynamic_stencil_reference == true) {
1452 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1453 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1454 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1455 i);
1456 }
1457 has_dynamic_stencil_reference = true;
1458 }
1459 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1460 if (has_dynamic_viewport_w_scaling_nv == true) {
1461 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1462 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1463 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1464 i);
1465 }
1466 has_dynamic_viewport_w_scaling_nv = true;
1467 }
1468 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1469 if (has_dynamic_discard_rectangle_ext == true) {
1470 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1471 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1472 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1473 i);
1474 }
1475 has_dynamic_discard_rectangle_ext = true;
1476 }
1477 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1478 if (has_dynamic_sample_locations_ext == true) {
1479 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1480 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1481 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1482 i);
1483 }
1484 has_dynamic_sample_locations_ext = true;
1485 }
1486 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1487 if (has_dynamic_exclusive_scissor_nv == true) {
1488 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1489 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1490 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1491 i);
1492 }
1493 has_dynamic_exclusive_scissor_nv = true;
1494 }
1495 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1496 if (has_dynamic_shading_rate_palette_nv == true) {
1497 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1498 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1499 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1500 i);
1501 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001502 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001503 }
1504 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1505 if (has_dynamic_viewport_course_sample_order_nv == true) {
1506 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1507 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1508 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1509 i);
1510 }
1511 has_dynamic_viewport_course_sample_order_nv = true;
1512 }
1513 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1514 if (has_dynamic_line_stipple == true) {
1515 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1516 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1517 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1518 i);
1519 }
1520 has_dynamic_line_stipple = true;
1521 }
Petr Kraus299ba622017-11-24 03:09:03 +01001522 }
1523 }
1524
Peter Chen85366392019-05-14 15:20:11 -04001525 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1526 if ((feedback_struct != nullptr) &&
1527 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001528 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1529 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1530 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1531 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1532 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001533 }
1534
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001535 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001536
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001537 // Collect active stages and other information
1538 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001539 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001540 bool has_eval = false;
1541 bool has_control = false;
1542 if (pCreateInfos[i].pStages != nullptr) {
1543 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1544 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1545
1546 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1547 has_control = true;
1548 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1549 has_eval = true;
1550 }
1551
1552 skip |= validate_string(
1553 "vkCreateGraphicsPipelines",
1554 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1555 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1556 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001557 }
1558
1559 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1560 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1561 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1562 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1563 pCreateInfos[i].pTessellationState,
1564 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1565 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1566
1567 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1568 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1569
1570 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1571 "VkPipelineTessellationDomainOriginStateCreateInfo",
1572 pCreateInfos[i].pTessellationState->pNext,
1573 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1574 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001575 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1576 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001577
1578 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1579 pCreateInfos[i].pTessellationState->flags,
1580 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1581 }
1582
1583 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1584 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1585 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1586 pCreateInfos[i].pInputAssemblyState,
1587 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1588 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1589
1590 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1591 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001592 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001593
1594 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1595 pCreateInfos[i].pInputAssemblyState->flags,
1596 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1597
1598 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1599 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1600 pCreateInfos[i].pInputAssemblyState->topology,
1601 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1602
1603 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1604 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1605 }
1606
1607 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001608 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001609
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001610 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001611 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1612 "vkCreateGraphicsPipelines: pararameter "
1613 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1614 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001615 }
1616
1617 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1618 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1619 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1620 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1621 pCreateInfos[i].pVertexInputState->pNext, 1,
1622 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001623 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1624 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001625 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1626 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001627 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001628 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1629 skip |=
1630 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1631 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1632 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1633 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1634 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1635
1636 skip |= validate_array(
1637 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1638 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1639 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1640 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1641
1642 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1643 for (uint32_t vertexBindingDescriptionIndex = 0;
1644 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1645 ++vertexBindingDescriptionIndex) {
1646 skip |= validate_ranged_enum(
1647 "vkCreateGraphicsPipelines",
1648 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1649 AllVkVertexInputRateEnums,
1650 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1651 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1652 }
1653 }
1654
1655 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1656 for (uint32_t vertexAttributeDescriptionIndex = 0;
1657 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1658 ++vertexAttributeDescriptionIndex) {
1659 skip |= validate_ranged_enum(
1660 "vkCreateGraphicsPipelines",
1661 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1662 AllVkFormatEnums,
1663 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1664 "VUID-VkVertexInputAttributeDescription-format-parameter");
1665 }
1666 }
1667
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001668 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001669 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1670 "vkCreateGraphicsPipelines: pararameter "
1671 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1672 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1673 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001674 }
1675
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001676 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001677 skip |=
1678 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1679 "vkCreateGraphicsPipelines: pararameter "
1680 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1681 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1682 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001683 }
1684
1685 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001686 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1687 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001688 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1689 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001690 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1691 "vkCreateGraphicsPipelines: parameter "
1692 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1693 "(%" PRIu32 ") is not distinct.",
1694 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001695 }
1696 vertex_bindings.insert(vertex_bind_desc.binding);
1697
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001698 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001699 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1700 "vkCreateGraphicsPipelines: parameter "
1701 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1702 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1703 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001704 }
1705
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001706 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001707 skip |=
1708 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1709 "vkCreateGraphicsPipelines: parameter "
1710 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1711 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1712 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001713 }
1714 }
1715
Peter Kohautc7d9d392018-07-15 00:34:07 +02001716 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001717 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1718 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001719 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1720 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001721 skip |= LogError(
1722 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001723 "vkCreateGraphicsPipelines: parameter "
1724 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1725 i, d, vertex_attrib_desc.location);
1726 }
1727 attribute_locations.insert(vertex_attrib_desc.location);
1728
1729 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1730 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001731 skip |= LogError(
1732 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001733 "vkCreateGraphicsPipelines: parameter "
1734 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1735 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1736 i, d, vertex_attrib_desc.binding, i);
1737 }
1738
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001739 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001740 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1741 "vkCreateGraphicsPipelines: parameter "
1742 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1743 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1744 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001745 }
1746
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001747 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001748 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1749 "vkCreateGraphicsPipelines: parameter "
1750 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1751 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1752 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001753 }
1754
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001755 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001756 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1757 "vkCreateGraphicsPipelines: parameter "
1758 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1759 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1760 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001761 }
1762 }
1763 }
1764
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001765 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1766 if (has_control && has_eval) {
1767 if (pCreateInfos[i].pTessellationState == nullptr) {
1768 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1769 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1770 "shader stage and a tessellation evaluation shader stage, "
1771 "pCreateInfos[%d].pTessellationState must not be NULL.",
1772 i, i);
1773 } else {
1774 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1775 skip |= validate_struct_pnext(
1776 "vkCreateGraphicsPipelines",
1777 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1778 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1779 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1780 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001781
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001782 skip |= validate_reserved_flags(
1783 "vkCreateGraphicsPipelines",
1784 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1785 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001786
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001787 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1788 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1789 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1790 "vkCreateGraphicsPipelines: invalid parameter "
1791 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1792 "should be >0 and <=%u.",
1793 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1794 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001795 }
1796 }
1797 }
1798
1799 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1800 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1801 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1802 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001803 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1804 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1805 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1806 "].pViewportState (=NULL) is not a valid pointer.",
1807 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001808 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001809 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1810
1811 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001812 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1813 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1814 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1815 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001816 }
1817
Petr Krausa6103552017-11-16 21:21:58 +01001818 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1819 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001820 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1821 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001822 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1823 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001824 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001825 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001826 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001827 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001828 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001829 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1830 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001831 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001832 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1833 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001834
1835 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001836 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001837 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001838 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001839
Dave Houlton142c4cb2018-10-17 15:04:41 -06001840 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1841 pCreateInfos[i].pViewportState->pNext);
1842 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1843 pCreateInfos[i].pViewportState->pNext);
1844 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1845 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001846 const auto vp_swizzle_struct =
1847 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001848 const auto vp_w_scaling_struct =
1849 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001850
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001851 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001852 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001853 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1854 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1855 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1856 ") is not 1.",
1857 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001858 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001859
Petr Krausa6103552017-11-16 21:21:58 +01001860 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001861 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1862 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1863 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1864 ") is not 1.",
1865 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001866 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001867
Dave Houlton142c4cb2018-10-17 15:04:41 -06001868 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1869 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001870 skip |= LogError(
1871 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1872 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1873 "disabled, but pCreateInfos[%" PRIu32
1874 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1875 ") is not 1.",
1876 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001877 }
1878
Jeff Bolz9af91c52018-09-01 21:53:57 -05001879 if (shading_rate_image_struct &&
1880 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001881 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1882 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1883 "disabled, but pCreateInfos[%" PRIu32
1884 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1885 ") is neither 0 nor 1.",
1886 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001887 }
1888
Petr Krausa6103552017-11-16 21:21:58 +01001889 } else { // multiViewport enabled
1890 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001891 skip |= LogError(
1892 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001893 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001894 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001895 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1896 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1897 "].pViewportState->viewportCount (=%" PRIu32
1898 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1899 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001900 }
Petr Krausa6103552017-11-16 21:21:58 +01001901
1902 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001903 skip |= LogError(
1904 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001905 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001906 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001907 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1908 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1909 "].pViewportState->scissorCount (=%" PRIu32
1910 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1911 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001912 }
1913 }
1914
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001915 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001916 skip |=
1917 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1918 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1919 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1920 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001921 }
1922
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001923 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001924 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1925 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1926 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1927 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1928 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001929 }
1930
Petr Krausa6103552017-11-16 21:21:58 +01001931 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1933 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1934 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1935 "].pViewportState->viewportCount (=%" PRIu32 ").",
1936 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001937 }
1938
Dave Houlton142c4cb2018-10-17 15:04:41 -06001939 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001940 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001941 skip |=
1942 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1943 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1944 ") must be zero or identical to pCreateInfos[%" PRIu32
1945 "].pViewportState->viewportCount (=%" PRIu32 ").",
1946 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001947 }
1948
Dave Houlton142c4cb2018-10-17 15:04:41 -06001949 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001950 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001951 skip |= LogError(
1952 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001953 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1954 "] "
1955 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1956 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1957 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001958 }
1959
Petr Krausa6103552017-11-16 21:21:58 +01001960 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001961 skip |= LogError(
1962 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001963 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1964 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001965 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1966 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001967 }
1968
1969 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001970 skip |= LogError(
1971 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001972 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1973 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001974 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1975 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001976 }
1977
Jeff Bolz3e71f782018-08-29 23:15:45 -05001978 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001979 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1980 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1981 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06001982 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001983 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1984 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1985 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1986 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001987 }
1988
Jeff Bolz9af91c52018-09-01 21:53:57 -05001989 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001990 shading_rate_image_struct->viewportCount > 0 &&
1991 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001992 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06001993 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001994 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001995 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1996 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001997 i, i);
1998 }
1999
Chris Mayer328d8212018-12-11 14:16:18 +01002000 if (vp_swizzle_struct) {
2001 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002002 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2003 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2004 " does "
2005 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2006 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002007 }
2008 }
2009
Petr Krausb3fcdb42018-01-09 22:09:09 +01002010 // validate the VkViewports
2011 if (!has_dynamic_viewport && viewport_state.pViewports) {
2012 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2013 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002014 const char *fn_name = "vkCreateGraphicsPipelines";
2015 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2016 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2017 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002018 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002019 }
2020 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002021
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002022 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002023 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2024 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2025 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2026 "VK_NV_clip_space_w_scaling extension is not enabled.",
2027 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002028 }
2029
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002030 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002031 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2032 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2033 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2034 "VK_EXT_discard_rectangles extension is not enabled.",
2035 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002036 }
2037
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002038 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002039 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2040 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2041 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2042 "VK_EXT_sample_locations extension is not enabled.",
2043 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002044 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002045
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002046 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002047 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2048 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2049 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2050 "VK_NV_scissor_exclusive extension is not enabled.",
2051 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002052 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002053
2054 if (coarse_sample_order_struct &&
2055 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2056 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002057 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2058 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2059 "] "
2060 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2061 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2062 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002063 }
2064
2065 if (coarse_sample_order_struct) {
2066 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002067 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002068 }
2069 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002070
2071 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2072 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002073 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2074 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2075 "] "
2076 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2077 ") "
2078 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2079 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002080 }
2081 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002082 skip |= LogError(
2083 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002084 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2085 "] "
2086 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2087 i);
2088 }
2089 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002090 }
2091
2092 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002093 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2094 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2095 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2096 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002097 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002098 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
2099 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2100 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002101 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002102 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002103 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002104 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002105 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002106 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002107 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002108 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2109 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002110
2111 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002112 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002113 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002114 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002115
2116 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002117 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002118 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2119 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2120
2121 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002122 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2124 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002125 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002126 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002127
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002128 skip |= validate_flags(
2129 "vkCreateGraphicsPipelines",
2130 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2131 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002132 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002133
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002134 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002135 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002136 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2137 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2138
2139 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002140 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2142 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2143
2144 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002145 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2146 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2147 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2148 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002149 }
John Zulauf7acac592017-11-06 11:15:53 -07002150 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002151 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002152 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2153 "vkCreateGraphicsPipelines(): parameter "
2154 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2155 i);
John Zulauf7acac592017-11-06 11:15:53 -07002156 }
2157 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2158 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2159 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002160 skip |= LogError(
2161 device,
2162
Dave Houlton413a6782018-05-22 13:01:54 -06002163 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002164 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002165 }
2166 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002167
2168 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2169 pCreateInfos[i].pRasterizationState->pNext);
2170
2171 if (line_state) {
2172 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2173 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2174 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2175 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002176 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2177 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2178 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2179 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002180 }
2181 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2182 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002183 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2184 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2185 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2186 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002187 }
2188 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2189 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002190 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2191 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2192 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2193 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002194 }
2195 }
2196 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2197 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2198 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002199 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2200 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2201 "range [1,256].",
2202 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002203 }
2204 }
2205 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002206 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002207 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2208 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002209 skip |=
2210 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2211 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2212 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2213 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002214 }
2215 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2216 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002217 skip |=
2218 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2219 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2220 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2221 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002222 }
2223 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2224 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002225 skip |=
2226 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2227 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2228 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2229 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002230 }
2231 if (line_state->stippledLineEnable) {
2232 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2233 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002234 skip |=
2235 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2236 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2237 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2238 "stippledRectangularLines feature.",
2239 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002240 }
2241 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2242 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002243 skip |=
2244 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2245 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2246 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2247 "stippledBresenhamLines feature.",
2248 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002249 }
2250 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2251 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002252 skip |=
2253 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2254 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2255 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2256 "stippledSmoothLines feature.",
2257 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002258 }
2259 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2260 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002261 skip |=
2262 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2263 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2264 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2265 "stippledRectangularLines and strictLines features.",
2266 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002267 }
2268 }
2269 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270 }
2271
Petr Krause91f7a12017-12-14 20:57:36 +01002272 bool uses_color_attachment = false;
2273 bool uses_depthstencil_attachment = false;
2274 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002275 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002276 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2277 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002278 const auto &subpasses_uses = subpasses_uses_it->second;
2279 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2280 uses_color_attachment = true;
2281 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2282 uses_depthstencil_attachment = true;
2283 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002284 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002285 }
2286
2287 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002288 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002289 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002290 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002291 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002292 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293
2294 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002295 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002297 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002298
2299 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002300 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002301 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2302 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2303
2304 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002305 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002306 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2307 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2308
2309 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2312 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002313 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002314
2315 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002316 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002317 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2318 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2319
2320 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002321 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002322 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2323 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2324
2325 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002326 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2328 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002329 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002330
2331 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002332 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002333 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2334 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002335 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002336
2337 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002338 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002339 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2340 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002341 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342
2343 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002344 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002345 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2346 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002347 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348
2349 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002350 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2352 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002353 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002354
2355 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002356 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002357 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2358 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002359 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002360
2361 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002362 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2364 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002365 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002366
2367 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002368 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002369 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2370 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002371 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002372
2373 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002374 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2375 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2376 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2377 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002378 }
2379 }
2380
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002381 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2382 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2383
Petr Krause91f7a12017-12-14 20:57:36 +01002384 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002385 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2386 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2387 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2388 pCreateInfos[i].pColorBlendState,
2389 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2390 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2391
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002392 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002393 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002394 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2395 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2396 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002397 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002398 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2399 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002400
2401 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002402 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002403 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002404 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002405
2406 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002407 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002408 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2409 pCreateInfos[i].pColorBlendState->logicOpEnable);
2410
2411 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002412 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002413 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2414 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002415 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002416 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002417
2418 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2419 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2420 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002421 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002422 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2423 ParameterName::IndexVector{i, attachmentIndex}),
2424 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2425
2426 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002427 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002428 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2429 ParameterName::IndexVector{i, attachmentIndex}),
2430 "VkBlendFactor", AllVkBlendFactorEnums,
2431 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002432 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002433
2434 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002435 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2437 ParameterName::IndexVector{i, attachmentIndex}),
2438 "VkBlendFactor", AllVkBlendFactorEnums,
2439 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002440 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002441
2442 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002443 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002444 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2445 ParameterName::IndexVector{i, attachmentIndex}),
2446 "VkBlendOp", AllVkBlendOpEnums,
2447 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002448 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002449
2450 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002451 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002452 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2453 ParameterName::IndexVector{i, attachmentIndex}),
2454 "VkBlendFactor", AllVkBlendFactorEnums,
2455 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002456 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002457
2458 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002459 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002460 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2461 ParameterName::IndexVector{i, attachmentIndex}),
2462 "VkBlendFactor", AllVkBlendFactorEnums,
2463 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002464 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465
2466 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2469 ParameterName::IndexVector{i, attachmentIndex}),
2470 "VkBlendOp", AllVkBlendOpEnums,
2471 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002472 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002473
2474 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002475 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002476 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2477 ParameterName::IndexVector{i, attachmentIndex}),
2478 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2479 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002480 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002481 }
2482 }
2483
2484 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002485 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2486 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2487 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2488 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002489 }
2490
2491 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2492 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2493 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002494 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002495 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002496 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2497 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002498 }
2499 }
2500 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002501
Petr Kraus9752aae2017-11-24 03:05:50 +01002502 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2503 if (pCreateInfos[i].basePipelineIndex != -1) {
2504 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002505 skip |=
2506 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002507 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002508 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002509 "and pCreateInfos->basePipelineIndex is not -1.",
2510 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002511 }
2512 }
2513
Petr Kraus9752aae2017-11-24 03:05:50 +01002514 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2515 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002516 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002517 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002518 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002519 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2520 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002521 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002522 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002523 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002524 skip |=
2525 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2526 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2527 "index into the pCreateInfos array, of size %d.",
2528 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002529 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002530 }
2531 }
2532
sfricke-samsung898cf222020-05-15 23:10:19 -07002533 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2534 skip |= LogError(
2535 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2536 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2537 i);
2538 }
2539
Petr Kraus9752aae2017-11-24 03:05:50 +01002540 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002541 if (!device_extensions.vk_nv_fill_rectangle) {
2542 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2543 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2545 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2546 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2547 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002548 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2549 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002550 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2551 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002552 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2553 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2554 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002555 }
2556 } else {
2557 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2558 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2559 (physical_device_features.fillModeNonSolid == false)) {
2560 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002561 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2562 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002563 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2564 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2565 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002567 }
Petr Kraus299ba622017-11-24 03:09:03 +01002568
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002569 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002570 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002571 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2572 "The line width state is static (pCreateInfos[%" PRIu32
2573 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2574 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2575 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2576 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002577 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002578 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002579 }
2580 }
2581
2582 return skip;
2583}
2584
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002585bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2586 uint32_t createInfoCount,
2587 const VkComputePipelineCreateInfo *pCreateInfos,
2588 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002589 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002590 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002591 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002592 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002594 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002595 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2596 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002597 skip |=
2598 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2599 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2600 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2601 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002602 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002603
2604 // Make sure compute stage is selected
2605 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002606 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2607 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2608 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002609 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002610 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002611 return skip;
2612}
2613
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002615 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002616 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002617
2618 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002619 const auto &features = physical_device_features;
2620 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002621
John Zulauf71968502017-10-26 13:51:15 -06002622 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2623 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002624 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2625 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2626 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2627 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002628 }
2629
2630 // Anistropy cannot be enabled in sampler unless enabled as a feature
2631 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002632 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2633 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2634 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002635 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002636 }
John Zulauf71968502017-10-26 13:51:15 -06002637
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002638 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2639 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002640 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2641 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2642 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2643 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002644 }
2645 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002646 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2647 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2648 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2649 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002650 }
2651 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002652 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2653 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2654 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2655 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002656 }
2657 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2658 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2659 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2660 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002661 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2662 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2663 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2664 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2665 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2666 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002667 }
2668 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002669 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2670 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2671 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002672 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002673 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002674 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2675 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2676 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002677 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002678 }
2679
2680 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2681 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002682 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2683 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002684 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2685 if (sampler_reduction != nullptr) {
2686 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2687 skip |= LogError(
2688 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2689 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2690 }
2691 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002692 }
2693
2694 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2695 // valid VkBorderColor value
2696 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2697 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2698 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002699 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2700 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002701 }
2702
2703 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2704 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002705 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002706 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2707 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2708 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002709 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2711 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2712 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002713 }
John Zulauf275805c2017-10-26 15:34:49 -06002714
2715 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002716 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002717 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2718 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002719 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2720 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2721 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002722 }
2723 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002724
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002725 // Check for valid Lod range
2726 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002727 skip |=
2728 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2729 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002730 }
2731
2732 // Check mipLodBias to device limit
2733 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002734 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2735 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2736 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002737 }
2738
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002739 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2740 if (sampler_conversion != nullptr) {
2741 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2742 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2743 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2744 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002745 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002746 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002747 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2748 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2749 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2750 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2751 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2752 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2753 }
2754 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002755
2756 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2757 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2758 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2759 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2760 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2761 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2762 }
2763 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2764 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2765 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2766 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2767 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2768 }
2769 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2770 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2771 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2772 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2773 pCreateInfo->minLod, pCreateInfo->maxLod);
2774 }
2775 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2776 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2777 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2778 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2779 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2780 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2781 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2782 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2783 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2784 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2785 }
2786 if (pCreateInfo->anisotropyEnable) {
2787 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2788 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2789 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2790 }
2791 if (pCreateInfo->compareEnable) {
2792 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2793 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2794 "pCreateInfo->compareEnable must be VK_FALSE");
2795 }
2796 if (pCreateInfo->unnormalizedCoordinates) {
2797 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2798 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2799 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2800 }
2801 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 }
2803
Tony-LunarG7337b312020-04-15 16:40:25 -06002804 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2805 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2806 if (!device_extensions.vk_ext_custom_border_color) {
2807 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2808 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2809 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2810 }
2811 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2812 if (!custom_create_info) {
2813 skip |=
2814 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2815 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2816 "struct in pNext chain.\n",
2817 string_VkBorderColor(pCreateInfo->borderColor));
2818 } else {
2819 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2820 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2821 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2822 !FormatIsSampledFloat(custom_create_info->format)))) {
2823 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2824 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2825 "whose type does not match\n",
2826 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2827 ;
2828 }
2829 }
2830 }
2831
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002832 return skip;
2833}
2834
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002835bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2836 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2837 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002838 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002839 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002840
2841 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2842 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2843 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2844 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002845 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2846 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2847 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2848 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2849 ++descriptor_index) {
2850 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002851 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002852 "vkCreateDescriptorSetLayout: required parameter "
2853 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2854 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855 }
2856 }
2857 }
2858
2859 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2860 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2861 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002862 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2863 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2864 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2865 "values.",
2866 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002867 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002868
2869 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2870 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2871 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2872 skip |=
2873 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2874 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2875 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2876 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2877 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2878 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002879 }
2880 }
2881 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002882 return skip;
2883}
2884
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002885bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2886 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002887 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002888 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2889 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2890 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002891 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2892 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002893}
2894
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002895bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2896 const VkWriteDescriptorSet *pDescriptorWrites,
2897 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002898 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002899
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002900 if (pDescriptorWrites != NULL) {
2901 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2902 // descriptorCount must be greater than 0
2903 if (pDescriptorWrites[i].descriptorCount == 0) {
2904 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002905 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2906 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002907 }
2908
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002909 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2910 if (validateDstSet) {
2911 // dstSet must be a valid VkDescriptorSet handle
2912 skip |= validate_required_handle(vkCallingFunction,
2913 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2914 pDescriptorWrites[i].dstSet);
2915 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916
2917 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2918 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2919 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2920 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2921 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2922 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2923 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002924 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2925 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002927 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2928 "%s(): if pDescriptorWrites[%d].descriptorType is "
2929 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2930 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2931 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2932 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002933 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2934 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002935 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2936 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002937 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2938 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002939 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002940 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2941 ParameterName::IndexVector{i, descriptor_index}),
2942 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002943 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944 }
2945 }
2946 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2947 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2948 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2949 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2950 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2951 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2952 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002953 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002954 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002955 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2956 "%s(): if pDescriptorWrites[%d].descriptorType is "
2957 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2958 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2959 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2960 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002961 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002962 const auto *robustness2_features =
2963 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2964 if (robustness2_features && robustness2_features->nullDescriptor) {
2965 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2966 ++descriptorIndex) {
2967 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2968 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2969 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2970 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2971 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2972 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2973 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2974 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2975 }
2976 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002977 }
2978 }
2979 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2980 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002981 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002982 }
2983
2984 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2985 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002986 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2988 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2989 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002990 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002991 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2992 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2993 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2994 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995 }
2996 }
2997 }
2998 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2999 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003000 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003001 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3002 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3003 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003004 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003005 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3006 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3007 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3008 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003009 }
3010 }
3011 }
3012 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003013 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3014 // or VkWriteDescriptorSetInlineUniformBlockEX
3015 if (pDescriptorWrites[i].pNext) {
3016 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003017 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003018 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003019 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003020 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3021 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3022 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3023 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003024 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003025 pDescriptorWrites[i].descriptorCount);
3026 }
3027 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003028 if (pnext_struct) {
3029 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003030 skip |= LogError(
3031 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3032 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3033 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003034 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003035 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003036 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003037 skip |= LogError(
3038 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3039 "%s(): accelerationStructureCount must be greater than 0 .");
3040 }
3041 }
3042 }
3043 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003044 }
3045 }
3046 return skip;
3047}
3048
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003049bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3050 const VkWriteDescriptorSet *pDescriptorWrites,
3051 uint32_t descriptorCopyCount,
3052 const VkCopyDescriptorSet *pDescriptorCopies) const {
3053 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3054}
3055
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003056bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003057 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003058 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003059 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3060}
3061
3062bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003063 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003064 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003065 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3066}
3067
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003068bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3069 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003070 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003072
3073 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3074 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3075 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003076 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3077 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003078 return skip;
3079}
3080
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003081bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003082 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003083 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003084
3085 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3086 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3088
Petr Krause7bb9e82019-08-11 21:34:43 +02003089 // Implicit VUs
3090 // validate only sType here; pointer has to be validated in core_validation
3091 const bool kNotRequired = false;
3092 const char *kNoVUID = nullptr;
3093 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3094 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3095 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003096
Petr Krause7bb9e82019-08-11 21:34:43 +02003097 if (pInfo) {
3098 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3099 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3100 skip |= validate_struct_pnext(
3101 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3102 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003103 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3104 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105
Petr Krause7bb9e82019-08-11 21:34:43 +02003106 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107
Petr Krause7bb9e82019-08-11 21:34:43 +02003108 // Explicit VUs
3109 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 skip |= LogError(
3111 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003112 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3113 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003114 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003115
3116 if (physical_device_features.inheritedQueries) {
3117 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003118 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003119 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003120 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003121 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003122 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003123 }
3124
3125 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003126 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003127 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003128 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003129 } else { // !pipelineStatisticsQuery
3130 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3131 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 }
Petr Kraus139757b2019-08-15 17:19:33 +02003133
3134 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3135 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003136 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003137 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3138 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003139 skip |= LogError(
3140 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003141 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3142 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3143 }
3144 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003145 }
3146
3147 return skip;
3148}
3149
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003150bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003151 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003152 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003153
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003154 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003155 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003156 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3157 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3158 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003159 }
3160 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003161 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3162 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3163 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003164 }
3165 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003166 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003167 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003168 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3169 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3170 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3171 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003172 }
3173 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003174
3175 if (pViewports) {
3176 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3177 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003178 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003179 skip |= manual_PreCallValidateViewport(
3180 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003181 }
3182 }
3183
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003184 return skip;
3185}
3186
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003187bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003188 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003189 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003190
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003191 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003192 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003193 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3194 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3195 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003196 }
3197 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003198 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3199 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3200 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003201 }
3202 } else { // multiViewport enabled
3203 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003204 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003205 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3206 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3207 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3208 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003209 }
3210 }
3211
Petr Kraus6260f0a2018-02-27 21:15:55 +01003212 if (pScissors) {
3213 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3214 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003215
Petr Kraus6260f0a2018-02-27 21:15:55 +01003216 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003217 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3218 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3219 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003220 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003221
Petr Kraus6260f0a2018-02-27 21:15:55 +01003222 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003223 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3224 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3225 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003226 }
3227
3228 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3229 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003230 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3231 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3232 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3233 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003234 }
3235
3236 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3237 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003238 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3239 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3240 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3241 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003242 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003243 }
3244 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003245
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003246 return skip;
3247}
3248
Jeff Bolz5c801d12019-10-09 10:38:45 -05003249bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003250 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003251
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003252 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003253 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3254 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003255 }
3256
3257 return skip;
3258}
3259
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003260bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003261 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003262 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003263 if (vertexCount == 0) {
3264 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3265 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003266 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003267 }
3268
3269 if (instanceCount == 0) {
3270 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3271 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003272 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003273 }
3274 return skip;
3275}
3276
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003277bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003278 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003279 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003280
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003281 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3283 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003284 }
3285 return skip;
3286}
3287
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003288bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003289 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003290 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003291 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003292 skip |=
3293 LogError(device, kVUID_PVError_DeviceFeature,
3294 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003295 }
3296 return skip;
3297}
3298
sfricke-samsungf692b972020-05-02 08:00:45 -07003299bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3300 VkDeviceSize countBufferOffset, bool khr) const {
3301 bool skip = false;
3302 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3303 if (offset & 3) {
3304 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3305 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3306 }
3307
3308 if (countBufferOffset & 3) {
3309 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3310 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3311 countBufferOffset);
3312 }
3313 return skip;
3314}
3315
3316bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3317 VkDeviceSize offset, VkBuffer countBuffer,
3318 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3319 uint32_t stride) const {
3320 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3321}
3322
3323bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3324 VkDeviceSize offset, VkBuffer countBuffer,
3325 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3326 uint32_t stride) const {
3327 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3328}
3329
3330bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3331 VkDeviceSize countBufferOffset, bool khr) const {
3332 bool skip = false;
3333 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3334 if (offset & 3) {
3335 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3336 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3337 }
3338
3339 if (countBufferOffset & 3) {
3340 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3341 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3342 countBufferOffset);
3343 }
3344 return skip;
3345}
3346
3347bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3348 VkDeviceSize offset, VkBuffer countBuffer,
3349 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3350 uint32_t stride) const {
3351 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3352}
3353
3354bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3355 VkDeviceSize offset, VkBuffer countBuffer,
3356 VkDeviceSize countBufferOffset,
3357 uint32_t maxDrawCount, uint32_t stride) const {
3358 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3359}
3360
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003361bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3362 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003363 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003364 bool skip = false;
3365 for (uint32_t rect = 0; rect < rectCount; rect++) {
3366 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003367 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3368 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003369 }
sfricke-samsung10867682020-04-25 02:20:39 -07003370 if (pRects[rect].rect.extent.width == 0) {
3371 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3372 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3373 }
3374 if (pRects[rect].rect.extent.height == 0) {
3375 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3376 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3377 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003378 }
3379 return skip;
3380}
3381
Andrew Fobel3abeb992020-01-20 16:33:22 -05003382bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3383 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3384 VkImageFormatProperties2 *pImageFormatProperties,
3385 const char *apiName) const {
3386 bool skip = false;
3387
3388 if (pImageFormatInfo != nullptr) {
3389 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3390 if (image_stencil_struct != nullptr) {
3391 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3392 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3393 // No flags other than the legal attachment bits may be set
3394 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3395 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003396 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3397 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3398 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3399 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3400 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003401 }
3402 }
3403 }
3404 }
3405
3406 return skip;
3407}
3408
3409bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3410 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3411 VkImageFormatProperties2 *pImageFormatProperties) const {
3412 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3413 "vkGetPhysicalDeviceImageFormatProperties2");
3414}
3415
3416bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3417 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3418 VkImageFormatProperties2 *pImageFormatProperties) const {
3419 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3420 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3421}
3422
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003423bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3424 VkImageLayout srcImageLayout, VkImage dstImage,
3425 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003426 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428
Dave Houltonf5217612018-02-02 16:18:52 -07003429 VkImageAspectFlags legal_aspect_flags =
3430 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 -07003431 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003432 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3433 }
3434
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003436 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003437 skip |= LogError(
3438 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003439 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003440 }
Dave Houltonf5217612018-02-02 16:18:52 -07003441 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(
3443 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003444 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003445 }
3446 }
3447 return skip;
3448}
3449
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003450bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3451 VkImageLayout srcImageLayout, VkImage dstImage,
3452 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003453 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003455
Dave Houltonf5217612018-02-02 16:18:52 -07003456 VkImageAspectFlags legal_aspect_flags =
3457 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 -07003458 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003459 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3460 }
3461
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003462 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003463 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 skip |= LogError(
3465 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003466 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3467 }
Dave Houltonf5217612018-02-02 16:18:52 -07003468 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003469 skip |= LogError(
3470 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003471 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3472 }
3473 }
3474 return skip;
3475}
3476
sfricke-samsung3999ef62020-02-09 17:05:59 -08003477bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3478 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3479 bool skip = false;
3480
3481 if (pRegions != nullptr) {
3482 for (uint32_t i = 0; i < regionCount; i++) {
3483 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003484 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3485 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003486 }
3487 }
3488 }
3489 return skip;
3490}
3491
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003492bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3493 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003494 uint32_t regionCount,
3495 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003496 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003497
Dave Houltonf5217612018-02-02 16:18:52 -07003498 VkImageAspectFlags legal_aspect_flags =
3499 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 -07003500 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003501 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3502 }
3503
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003504 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003505 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003506 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3507 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3508 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003509 }
3510 }
3511 return skip;
3512}
3513
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003514bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3515 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003516 uint32_t regionCount,
3517 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003518 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003519
Dave Houltonf5217612018-02-02 16:18:52 -07003520 VkImageAspectFlags legal_aspect_flags =
3521 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 -07003522 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003523 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3524 }
3525
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003526 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003527 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003528 skip |= LogError(
3529 device, kVUID_PVError_UnrecognizedValue,
3530 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3531 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 }
3533 }
3534 return skip;
3535}
3536
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003537bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003538 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3539 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003540 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003541
3542 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003543 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3544 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3545 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003546 }
3547
3548 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003549 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3550 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3551 "), must be greater than zero and less than or equal to 65536.",
3552 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003553 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003554 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3555 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3556 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003557 }
3558 return skip;
3559}
3560
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003561bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003562 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003563 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003564
3565 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003566 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3567 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3568 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003569 }
3570
3571 if (size != VK_WHOLE_SIZE) {
3572 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003573 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003574 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3575 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003576 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003577 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3578 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003579 }
3580 }
3581 return skip;
3582}
3583
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003584bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003585 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003586 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003587 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003588
3589 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003590 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3591 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3592 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3593 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003594 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3595 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3596 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003597 }
3598
3599 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3600 // queueFamilyIndexCount uint32_t values
3601 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003602 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3603 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3604 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3605 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606 }
3607 }
3608
Dave Houlton413a6782018-05-22 13:01:54 -06003609 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003611 }
3612
3613 return skip;
3614}
3615
Jeff Bolz5c801d12019-10-09 10:38:45 -05003616bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003617 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003618
3619 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003620 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3621 if (present_regions) {
3622 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003623 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003624 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3625 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3627 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3628 "extension swapchainCount is %i. These values must be equal.",
3629 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003630 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003631 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003632 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3633 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003634 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3635 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3636 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003637 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003638 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003640 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003641 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003642 }
3643 }
3644
3645 return skip;
3646}
3647
3648#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003649bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3650 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3651 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003652 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003653 bool skip = false;
3654
3655 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003656 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3657 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003658 }
3659
3660 return skip;
3661}
3662#endif // VK_USE_PLATFORM_WIN32_KHR
3663
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003664bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003665 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003666 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003667 bool skip = false;
3668
3669 if (pCreateInfo) {
3670 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003671 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3672 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003673 }
3674
3675 if (pCreateInfo->pPoolSizes) {
3676 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3677 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003678 skip |= LogError(
3679 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003680 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003681 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003682 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3683 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003684 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3685 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3686 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3687 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3688 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003689 }
Petr Krausc8655be2017-09-27 18:56:51 +02003690 }
3691 }
3692 }
3693
3694 return skip;
3695}
3696
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003697bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003698 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003699 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003700
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003701 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003702 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003703 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3704 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3705 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003706 }
3707
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003708 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003709 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003710 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3711 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3712 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003713 }
3714
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003715 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003716 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003717 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3718 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3719 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003720 }
3721
3722 return skip;
3723}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003724
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003725bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003726 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003727 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003728
3729 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003730 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3731 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003732 }
3733 return skip;
3734}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003735
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003736bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3737 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003738 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003739 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003740
3741 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003742 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003743 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3745 "vkCmdDispatch(): baseGroupX (%" PRIu32
3746 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3747 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003748 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003749 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3750 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3751 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3752 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003753 }
3754
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003755 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003756 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003757 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3758 "vkCmdDispatch(): baseGroupY (%" PRIu32
3759 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3760 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003761 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003762 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3763 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3764 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3765 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003766 }
3767
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003768 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003769 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3771 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3772 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3773 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003774 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003775 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3776 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3777 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3778 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003779 }
3780
3781 return skip;
3782}
3783
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003784bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3785 VkPipelineBindPoint pipelineBindPoint,
3786 VkPipelineLayout layout, uint32_t set,
3787 uint32_t descriptorWriteCount,
3788 const VkWriteDescriptorSet *pDescriptorWrites) const {
3789 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3790}
3791
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003792bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3793 uint32_t firstExclusiveScissor,
3794 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003795 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003796 bool skip = false;
3797
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003798 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003799 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003800 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003801 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3802 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3803 ") is not 0.",
3804 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003805 }
3806 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003807 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003808 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3809 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3810 ") is not 1.",
3811 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003812 }
3813 } else { // multiViewport enabled
3814 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003815 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003816 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3817 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3818 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3819 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003820 }
3821 }
3822
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003823 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003824 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3825 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3826 ") must be less than maxViewports (=%" PRIu32 ").",
3827 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003828 }
3829
3830 if (pExclusiveScissors) {
3831 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3832 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3833
3834 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003835 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3836 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3837 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003838 }
3839
3840 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003841 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3842 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3843 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003844 }
3845
3846 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3847 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003848 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3849 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3850 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3851 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003852 }
3853
3854 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3855 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003856 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3857 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3858 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3859 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003860 }
3861 }
3862 }
3863
3864 return skip;
3865}
3866
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003867bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3868 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003869 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003870 bool skip = false;
3871 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003872 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3873 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3874 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003875 } else {
3876 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3877 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003878 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3879 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3880 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3881 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003882 }
3883 }
3884
3885 return skip;
3886}
3887
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003888bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3889 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003890 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003891 bool skip = false;
3892
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003893 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003894 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003895 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003896 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3897 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3898 ") is not 0.",
3899 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003900 }
3901 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003902 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003903 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3904 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3905 ") is not 1.",
3906 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003907 }
3908 }
3909
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003910 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003911 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3912 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3913 ") must be less than maxViewports (=%" PRIu32 ").",
3914 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003915 }
3916
3917 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003918 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003919 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3920 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3921 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3922 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003923 }
3924
3925 return skip;
3926}
3927
Jeff Bolz5c801d12019-10-09 10:38:45 -05003928bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3929 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3930 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003931 bool skip = false;
3932
Dave Houlton142c4cb2018-10-17 15:04:41 -06003933 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003934 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3935 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3936 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003937 }
3938
3939 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003940 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003941 }
3942
3943 return skip;
3944}
3945
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003946bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003947 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003948 bool skip = false;
3949
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003950 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003951 skip |= LogError(
3952 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003953 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3954 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003956 }
3957
3958 return skip;
3959}
3960
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003961bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3962 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003963 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003964 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003965 static const int condition_multiples = 0b0011;
3966 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003967 skip |= LogError(
3968 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003969 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003970 }
Lockee1c22882019-06-10 16:02:54 -06003971 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003972 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3973 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3974 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3975 stride);
Lockee1c22882019-06-10 16:02:54 -06003976 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003977 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003978 skip |= LogError(
3979 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3980 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003981 }
3982
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003983 return skip;
3984}
3985
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003986bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3987 VkDeviceSize offset, VkBuffer countBuffer,
3988 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003989 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003990 bool skip = false;
3991
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003992 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003993 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3994 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3995 "), is not a multiple of 4.",
3996 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003997 }
3998
3999 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004000 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4001 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4002 "), is not a multiple of 4.",
4003 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004004 }
4005
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004006 return skip;
4007}
4008
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004009bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004010 const VkAllocationCallbacks *pAllocator,
4011 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004012 bool skip = false;
4013
4014 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4015 if (pCreateInfo != nullptr) {
4016 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4017 // VkQueryPipelineStatisticFlagBits values
4018 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4019 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004020 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4021 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4022 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4023 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004024 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004025 if (pCreateInfo->queryCount == 0) {
4026 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4027 "vkCreateQueryPool(): queryCount must be greater than zero.");
4028 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004029 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004030 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004031}
4032
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004033bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4034 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004035 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004036 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4037 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004038}
4039
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004040void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004041 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4042 VkResult result) {
4043 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004044 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004045}
4046
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004047void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004048 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4049 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004050 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004051 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004052 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004053}
4054
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004055void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4056 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004057 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004058 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004059 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004060}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004061
4062bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004063 const VkAllocationCallbacks *pAllocator,
4064 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004065 bool skip = false;
4066
4067 if (pAllocateInfo) {
4068 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4069 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004070 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4071 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004072 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004073
4074 VkMemoryAllocateFlags flags = 0;
4075 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4076 if (flags_info) {
4077 flags = flags_info->flags;
4078 }
4079
4080 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4081 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4082 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4084 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4085 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004086 }
4087
4088#ifdef VK_USE_PLATFORM_WIN32_KHR
4089 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4090#endif
4091 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4092 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4093#ifdef VK_USE_PLATFORM_ANDROID_KHR
4094 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4095#endif
4096
4097 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004098 skip |= LogError(
4099 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004100 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4101 }
4102 if (
4103#ifdef VK_USE_PLATFORM_WIN32_KHR
4104 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4105#endif
4106 (import_memory_fd && import_memory_fd->handleType) ||
4107#ifdef VK_USE_PLATFORM_ANDROID_KHR
4108 (import_memory_ahb && import_memory_ahb->buffer) ||
4109#endif
4110 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004111 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4112 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004113 }
4114 }
4115
4116 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004117 VkBool32 capture_replay = false;
4118 VkBool32 buffer_device_address = false;
4119 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4120 if (vulkan_12_features) {
4121 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4122 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4123 } else {
4124 const auto *bda_features =
4125 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4126 if (bda_features) {
4127 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4128 buffer_device_address = bda_features->bufferDeviceAddress;
4129 }
4130 }
4131 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004132 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4133 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4134 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004135 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004136 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004137 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4138 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004139 }
4140 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004141 }
4142 return skip;
4143}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004144
Jason Macnak192fa0e2019-07-26 15:07:16 -07004145bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004146 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004147 bool skip = false;
4148
4149 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4150 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4151 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004152 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004153 } else {
4154 uint32_t vertex_component_size = 0;
4155 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4156 vertex_component_size = 4;
4157 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4158 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4159 vertex_component_size = 2;
4160 }
4161 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004162 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004163 }
4164 }
4165
4166 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4167 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004168 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004169 } else {
4170 uint32_t index_element_size = 0;
4171 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4172 index_element_size = 4;
4173 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4174 index_element_size = 2;
4175 }
4176 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004178 }
4179 }
4180 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4181 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004182 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004183 }
4184 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004185 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004186 }
4187 }
4188
4189 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004190 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004191 }
4192
4193 return skip;
4194}
4195
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004196bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4197 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004198 bool skip = false;
4199
4200 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004201 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004202 }
4203 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004204 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004205 }
4206
4207 return skip;
4208}
4209
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004210bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4211 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004212 bool skip = false;
4213 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004214 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004215 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004216 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004217 }
4218 return skip;
4219}
4220
4221bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004222 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004223 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004224 bool skip = false;
4225 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004226 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4227 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4228 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004229 }
4230 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004231 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4232 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4233 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004234 }
4235 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4236 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004237 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4238 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4239 "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 -07004240 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004241 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004242 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004243 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4244 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004245 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4246 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004247 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004248 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004249 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4250 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4251 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004252 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004253 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004254 uint64_t total_triangle_count = 0;
4255 for (uint32_t i = 0; i < info.geometryCount; i++) {
4256 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004257
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004258 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004259
Jason Macnak5c954952019-07-09 15:46:12 -07004260 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4261 continue;
4262 }
4263 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4264 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004265 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004266 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4267 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4268 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004269 }
4270 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004271 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4272 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4273 for (uint32_t i = 1; i < info.geometryCount; i++) {
4274 const VkGeometryNV &geometry = info.pGeometries[i];
4275 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004276 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4278 "info.pGeometries[0].geometryType.",
4279 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004280 }
4281 }
4282 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004283 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4284 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4285 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4286 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4287 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4288 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4289 }
4290 }
4291 skip |=
4292 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004293 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004294 return skip;
4295}
4296
Ricardo Garciaa4935972019-02-21 17:43:18 +01004297bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4298 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004299 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004300 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004301 if (pCreateInfo) {
4302 if ((pCreateInfo->compactedSize != 0) &&
4303 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004304 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4305 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4306 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4307 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004308 }
Jason Macnak5c954952019-07-09 15:46:12 -07004309
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004310 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004311 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004312 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004313 return skip;
4314}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004315
Jeff Bolz5c801d12019-10-09 10:38:45 -05004316bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4317 const VkAccelerationStructureInfoNV *pInfo,
4318 VkBuffer instanceData, VkDeviceSize instanceOffset,
4319 VkBool32 update, VkAccelerationStructureNV dst,
4320 VkAccelerationStructureNV src, VkBuffer scratch,
4321 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004322 bool skip = false;
4323
4324 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004325 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004326 }
4327
4328 return skip;
4329}
4330
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004331bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4332 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4333 VkAccelerationStructureKHR *pAccelerationStructure) const {
4334 bool skip = false;
4335
4336 if (pCreateInfo) {
4337 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4338 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4339 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4340 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4341 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4342 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4343 i);
4344 }
4345 }
4346
4347 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4348 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4349 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4350 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4351 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4352 i);
4353 }
4354 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004355 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4356 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4357 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4358 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4359 skip |= LogError(
4360 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4361 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4362 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4363 }
4364 }
4365 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4366 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4367 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4368 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4369 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4370 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4371 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4372 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4373 }
4374 }
4375 }
4376
4377 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4378 pCreateInfo->maxGeometryCount != 1) {
4379 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4380 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4381 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004382 }
sourav parmard1521802020-06-07 21:49:02 -07004383 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4384 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4385 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4386 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4387 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004388
4389 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4390 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4391 skip |= LogError(
4392 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4393 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4394 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4395 }
4396
4397 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4398 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4399 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4400 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4401 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4402 }
4403
4404 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4405 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4406 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4407 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4408 if (geometry_type != first_geometry_type) {
4409 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4410 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4411 "pGeometryInfos[0].geometryType.",
4412 i);
4413 }
4414 }
4415 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004416 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4417 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4418 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4419 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4420 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4421 "maxGeometryCount %d.",
4422 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4423 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004424 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004425 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4426 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4427 if (pCreateInfo->deviceAddress != 0) {
4428 skip |=
4429 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4430 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4431 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4432 }
4433 }
sourav parmar83c31b12020-05-06 12:30:54 -07004434 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4435 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4436 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4437 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004438 return skip;
4439}
4440
Jason Macnak5c954952019-07-09 15:46:12 -07004441bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4442 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004443 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004444 bool skip = false;
4445 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004446 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4447 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004448 }
4449 return skip;
4450}
4451
Peter Chen85366392019-05-14 15:20:11 -04004452bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4453 uint32_t createInfoCount,
4454 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4455 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004456 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004457 bool skip = false;
4458
4459 for (uint32_t i = 0; i < createInfoCount; i++) {
4460 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4461 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004462 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004463 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4464 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4465 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4466 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004467 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004468
4469 const auto *pipeline_cache_contol_features =
4470 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4471 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4472 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4473 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4474 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4475 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4476 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4477 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4478 }
4479 }
4480
sourav parmarf4a78252020-04-10 13:04:21 -07004481 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4482 skip |=
4483 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4484 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4485 }
4486 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4487 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4488 skip |=
4489 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4490 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4491 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4492 }
4493 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4494 if (pCreateInfos[i].basePipelineIndex != -1) {
4495 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4496 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4497 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4498 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4499 "and pCreateInfos->basePipelineIndex is not -1.");
4500 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004501 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4502 skip |=
4503 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4504 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4505 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4506 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4507 "that element.");
4508 }
sourav parmarf4a78252020-04-10 13:04:21 -07004509 }
4510 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4511 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4512 skip |=
4513 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4514 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4515 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4516 "commands pCreateInfos parameter.");
4517 }
4518 } else {
4519 if (pCreateInfos[i].basePipelineIndex != -1) {
4520 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4521 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4522 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4523 }
4524 }
4525 }
4526 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4527 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4528 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4529 }
4530 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4531 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4532 "vkCreateRayTracingPipelinesNV: flags must not include "
4533 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4534 }
4535 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4536 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4537 "vkCreateRayTracingPipelinesNV: flags must not include "
4538 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4539 }
4540 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4541 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4542 "vkCreateRayTracingPipelinesNV: flags must not include "
4543 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4544 }
4545 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4546 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4547 "vkCreateRayTracingPipelinesNV: flags must not include "
4548 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4549 }
4550 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4551 skip |= LogError(
4552 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4553 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4554 }
4555 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4556 skip |= LogError(
4557 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4558 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4559 }
Peter Chen85366392019-05-14 15:20:11 -04004560 }
4561
4562 return skip;
4563}
4564
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004565bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4566 uint32_t createInfoCount,
4567 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4568 const VkAllocationCallbacks *pAllocator,
4569 VkPipeline *pPipelines) const {
4570 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004571 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4572 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4573 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4574 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4575 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004576 for (uint32_t i = 0; i < createInfoCount; i++) {
4577 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4578 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4579 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4580 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4581 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4582 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4583 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4584 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004585 const auto *pipeline_cache_contol_features =
4586 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4587 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4588 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4589 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4590 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4591 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4592 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4593 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4594 }
4595 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004596 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4597 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4598 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4599 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4600 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4601 }
4602 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4603 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4604 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4605 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4606 }
4607 }
4608
sourav parmarf4a78252020-04-10 13:04:21 -07004609 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4610 skip |=
4611 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4612 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4613 }
4614 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4615 if (pCreateInfos[i].pLibraryInterface == NULL)
4616 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4617 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4618 }
4619 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4620 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4621 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4622 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4623 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4624 skip |= LogError(
4625 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4626 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4627 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4628 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4629 "must not be VK_SHADER_UNUSED_KHR");
4630 }
4631 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4632 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4633 skip |= LogError(
4634 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4635 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4636 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4637 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4638 "element must not be VK_SHADER_UNUSED_KHR");
4639 }
4640 }
4641 }
4642 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4643 if (pCreateInfos[i].basePipelineIndex != -1) {
4644 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4645 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4646 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4647 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4648 "and pCreateInfos->basePipelineIndex is not -1.");
4649 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004650 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4651 skip |=
4652 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4653 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4654 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4655 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4656 "element.");
4657 }
sourav parmarf4a78252020-04-10 13:04:21 -07004658 }
4659 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4660 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4661 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4662 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4663 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4664 "commands pCreateInfos parameter %d.",
4665 pCreateInfos[i].basePipelineIndex, createInfoCount);
4666 }
4667 } else {
4668 if (pCreateInfos[i].basePipelineIndex != -1) {
4669 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4670 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4671 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4672 }
4673 }
4674 }
4675 if (pCreateInfos[i].libraries.libraryCount == 0) {
4676 if (pCreateInfos[i].stageCount == 0) {
4677 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4678 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4679 }
4680 if (pCreateInfos[i].groupCount == 0) {
4681 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4682 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4683 }
4684 } else {
4685 if (pCreateInfos[i].pLibraryInterface == NULL) {
4686 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4687 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4688 }
4689 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004690 }
4691
4692 return skip;
4693}
4694
Mike Schuchardt21638df2019-03-16 10:52:02 -07004695#ifdef VK_USE_PLATFORM_WIN32_KHR
4696bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4697 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004698 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004699 bool skip = false;
4700 if (!device_extensions.vk_khr_swapchain)
4701 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4702 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4703 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4704 if (!device_extensions.vk_khr_surface)
4705 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4706 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4707 skip |=
4708 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4709 if (!device_extensions.vk_ext_full_screen_exclusive)
4710 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4711 skip |= validate_struct_type(
4712 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4713 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4714 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4715 if (pSurfaceInfo != NULL) {
4716 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4717 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4718 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4719
4720 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4721 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4722 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4723 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004724 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4725 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004726
4727 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4728 }
4729 return skip;
4730}
4731#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004732
4733bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4734 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004735 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004736 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4737 bool skip = false;
4738 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4739 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4740 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4741 }
4742 return skip;
4743}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004744
4745bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004746 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004747 bool skip = false;
4748
4749 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004750 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4751 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004752 }
4753
4754 return skip;
4755}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004756
4757bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004758 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004759 bool skip = false;
4760
4761 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004762 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4763 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004764 }
4765
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004766 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004767 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004768 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4769 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004770 }
4771
4772 return skip;
4773}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004774
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004775bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4776 uint32_t bindingCount, const VkBuffer *pBuffers,
4777 const VkDeviceSize *pOffsets) const {
4778 bool skip = false;
4779 if (firstBinding > device_limits.maxVertexInputBindings) {
4780 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4781 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4782 device_limits.maxVertexInputBindings);
4783 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4784 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4785 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4786 "maxVertexInputBindings (%u)",
4787 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4788 }
4789
Jeff Bolz165818a2020-05-08 11:19:03 -05004790 for (uint32_t i = 0; i < bindingCount; ++i) {
4791 if (pBuffers[i] == VK_NULL_HANDLE) {
4792 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4793 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4794 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4795 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4796 } else {
4797 if (pOffsets[i] != 0) {
4798 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4799 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4800 }
4801 }
4802 }
4803 }
4804
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004805 return skip;
4806}
4807
Mark Lobodzinski84988402019-09-11 15:27:30 -06004808bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004809 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004810 bool skip = false;
4811 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004812 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4813 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004814 }
4815 return skip;
4816}
4817
4818bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004819 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004820 bool skip = false;
4821 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004822 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4823 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004824 }
4825 return skip;
4826}
Petr Kraus3d720392019-11-13 02:52:39 +01004827
4828bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4829 VkSemaphore semaphore, VkFence fence,
4830 uint32_t *pImageIndex) const {
4831 bool skip = false;
4832
4833 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004834 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4835 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004836 }
4837
4838 return skip;
4839}
4840
4841bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4842 uint32_t *pImageIndex) const {
4843 bool skip = false;
4844
4845 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004846 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4847 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004848 }
4849
4850 return skip;
4851}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004852
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004853bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4854 uint32_t firstBinding, uint32_t bindingCount,
4855 const VkBuffer *pBuffers,
4856 const VkDeviceSize *pOffsets,
4857 const VkDeviceSize *pSizes) const {
4858 bool skip = false;
4859
4860 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4861 for (uint32_t i = 0; i < bindingCount; ++i) {
4862 if (pOffsets[i] & 3) {
4863 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4864 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4865 }
4866 }
4867
4868 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4869 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4870 "%s: The firstBinding(%" PRIu32
4871 ") index is greater than or equal to "
4872 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4873 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4874 }
4875
4876 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4877 skip |=
4878 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4879 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4880 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4881 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4882 }
4883
4884 for (uint32_t i = 0; i < bindingCount; ++i) {
4885 // pSizes is optional and may be nullptr.
4886 if (pSizes != nullptr) {
4887 if (pSizes[i] != VK_WHOLE_SIZE &&
4888 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4889 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4890 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4891 ") is not VK_WHOLE_SIZE and is greater than "
4892 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4893 cmd_name, i, pSizes[i]);
4894 }
4895 }
4896 }
4897
4898 return skip;
4899}
4900
4901bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4902 uint32_t firstCounterBuffer,
4903 uint32_t counterBufferCount,
4904 const VkBuffer *pCounterBuffers,
4905 const VkDeviceSize *pCounterBufferOffsets) const {
4906 bool skip = false;
4907
4908 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4909 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4910 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4911 "%s: The firstCounterBuffer(%" PRIu32
4912 ") index is greater than or equal to "
4913 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4914 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4915 }
4916
4917 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4918 skip |=
4919 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4920 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4921 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4922 cmd_name, firstCounterBuffer, counterBufferCount,
4923 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4924 }
4925
4926 return skip;
4927}
4928
4929bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4930 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4931 const VkBuffer *pCounterBuffers,
4932 const VkDeviceSize *pCounterBufferOffsets) const {
4933 bool skip = false;
4934
4935 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4936 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4937 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4938 "%s: The firstCounterBuffer(%" PRIu32
4939 ") index is greater than or equal to "
4940 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4941 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4942 }
4943
4944 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4945 skip |=
4946 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4947 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4948 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4949 cmd_name, firstCounterBuffer, counterBufferCount,
4950 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4951 }
4952
4953 return skip;
4954}
4955
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004956bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4957 uint32_t firstInstance, VkBuffer counterBuffer,
4958 VkDeviceSize counterBufferOffset,
4959 uint32_t counterOffset, uint32_t vertexStride) const {
4960 bool skip = false;
4961
4962 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004963 skip |= LogError(
4964 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004965 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4966 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4967 }
4968
4969 return skip;
4970}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004971
4972bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4973 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4974 const VkAllocationCallbacks *pAllocator,
4975 VkSamplerYcbcrConversion *pYcbcrConversion,
4976 const char *apiName) const {
4977 bool skip = false;
4978
4979 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004980 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004981 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02004982 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
4983 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
4984 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07004985 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02004986 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004987 }
sfricke-samsung83d98122020-07-04 06:21:15 -07004988
4989 const VkComponentMapping components = pCreateInfo->components;
4990 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
4991 if (FormatIsXChromaSubsampled(pCreateInfo->format) == true) {
4992 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
4993 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
4994 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
4995 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
4996 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.g));
4997 }
4998
4999 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5000 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5001 skip |=
5002 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5003 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5004 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5005 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.a));
5006 }
5007
5008 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5009 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5010 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
5011 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5012 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
5013 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.r));
5014 }
5015
5016 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5017 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5018 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
5019 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5020 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
5021 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.b));
5022 }
5023
5024 // If one is identity, both need to be
5025 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5026 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5027 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5028 skip |= LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
5029 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5030 "are an identity swizzle, then both need to be an identity swizzle.",
5031 apiName, string_VkFormat(pCreateInfo->format), string_VkComponentSwizzle(components.r),
5032 string_VkComponentSwizzle(components.b));
5033 }
5034 }
5035
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005036 return skip;
5037}
5038
5039bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5040 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5041 const VkAllocationCallbacks *pAllocator,
5042 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5043 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5044 "vkCreateSamplerYcbcrConversion");
5045}
5046
5047bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5048 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5049 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5050 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5051 "vkCreateSamplerYcbcrConversionKHR");
5052}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005053
5054bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5055 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5056 bool skip = false;
5057 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5058 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5059
5060 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005061 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5062 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5063 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5064 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5065 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005066 }
5067 return skip;
5068}
sourav parmara96ab1a2020-04-25 16:28:23 -07005069
5070bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5071 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5072 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005073 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5074 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5075 skip |=
5076 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5077 "vkCopyAccelerationStructureToMemoryKHR: the "
5078 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5079 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005080 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5081 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5082 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5083 }
5084 return skip;
5085}
5086
5087bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5088 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5089 bool skip = false;
5090 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5091 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5092 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5093 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5094 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005095 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5096 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005097 skip |= LogError(
5098 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5099 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5100 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5101 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005102 return skip;
5103}
5104
5105bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5106 const char *api_name) const {
5107 bool skip = false;
5108 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5109 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5110 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5111 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5112 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5113 api_name);
5114 }
5115 return skip;
5116}
5117
5118bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5119 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5120 bool skip = false;
5121 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005122 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5123 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5124 skip |= LogError(
5125 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5126 "vkCopyAccelerationStructureKHR(): the "
5127 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5128 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005129 return skip;
5130}
5131
5132bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5133 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5134 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005135 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5136 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005137 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5138 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5139 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5140 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005141 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5142 return skip;
5143}
5144
5145bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005146 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005147 bool skip = false;
5148 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005149 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005150 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005151 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005152 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5153 }
5154 return skip;
5155}
5156
5157bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5158 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5159 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005160 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5161 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5162 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5163 skip |=
5164 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5165 "vkCopyMemoryToAccelerationStructureKHR() :the "
5166 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5167 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005168 return skip;
5169}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005170
sourav parmara96ab1a2020-04-25 16:28:23 -07005171bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5172 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5173 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005174 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5175 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005176 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5177 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5178 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5179 }
sourav parmar83c31b12020-05-06 12:30:54 -07005180 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5181 return skip;
5182}
5183bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5184 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5185 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5186 bool skip = false;
5187 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5188 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5189 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5190 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5191 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5192 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5193 }
5194 return skip;
5195}
5196bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5197 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5198 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5199 bool skip = false;
5200 if (dataSize < accelerationStructureCount * stride) {
5201 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5202 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5203 "accelerationStructureCount (%d) *stride(%zu).",
5204 dataSize, accelerationStructureCount, stride);
5205 }
5206 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5207 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5208 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5209 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5210 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5211 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5212 }
5213 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5214 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5215 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5216 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5217 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5218 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5219 stride);
5220 }
5221 }
5222 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5223 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5224 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5225 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5226 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5227 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5228 stride);
5229 }
5230 }
5231 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5232 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5233 skip |=
5234 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5235 "vkWriteAccelerationStructuresPropertiesKHR: the "
5236 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5237 "feature must be enabled ");
5238 }
5239 return skip;
5240}
5241bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5242 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5243 bool skip = false;
5244 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5245 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5246 skip |= LogError(device,
5247 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5248 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5249 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5250 "must be enabled to call this function.");
5251 }
5252 return skip;
5253}
5254
5255bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5256 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5257 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5258 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5259 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5260 uint32_t width, uint32_t height, uint32_t depth) const {
5261 bool skip = false;
5262 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5263 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5264 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5265 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5266 }
5267 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5268 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5269 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5270 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5271 }
5272 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5273 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5274 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5275 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5276 }
5277 // hitShader
5278 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5279 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5280 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5281 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5282 }
5283 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5284 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5285 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5286 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5287 }
5288 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5289 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5290 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5291 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5292 }
5293
5294 // missShader
5295 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5296 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5297 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5298 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5299 }
5300 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5301 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5302 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5303 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5304 }
5305 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5306 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5307 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5308 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5309 }
5310
5311 // raygenShader
5312 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5313 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5314 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5315 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5316 }
5317 return skip;
5318}
5319
5320bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5321 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5322 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5323 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5324 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5325 VkBuffer buffer, VkDeviceSize offset) const {
5326 bool skip = false;
5327 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5328 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5329 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5330 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5331 "feature must be enabled.");
5332 }
5333 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5334 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5335 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5336 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5337 }
5338 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5339 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5340 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5341 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5342 }
5343 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5344 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5345 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5346 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5347 }
5348 // hitShader
5349 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5350 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5351 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5352 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5353 }
5354 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5355 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5356 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5357 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5358 }
5359 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5360 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5361 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5362 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5363 }
5364
5365 // missShader
5366 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5367 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5368 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5369 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5370 }
5371 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5372 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5373 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5374 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5375 }
5376 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5377 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5378 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5379 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5380 }
5381
5382 // raygenShader
5383 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5384 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5385 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5386 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5387 }
5388 return skip;
5389}
5390bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5391 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5392 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5393 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5394 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5395 uint32_t width, uint32_t height, uint32_t depth) const {
5396 bool skip = false;
5397 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5398 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5399 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5400 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5401 }
5402 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5403 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5404 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5405 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5406 }
5407 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5408 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5409 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5410 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5411 }
5412
5413 // hitShader
5414 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5415 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5416 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5417 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5418 }
5419 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5420 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5421 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5422 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5423 }
5424 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5425 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5426 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5427 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5428 }
5429
5430 // missShader
5431 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5432 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5433 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5434 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5435 }
5436 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5437 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5438 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5439 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5440 }
5441 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5442 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5443 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5444 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5445 }
5446
5447 // raygenShader
5448 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5449 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5450 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005451 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5452 }
5453 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5454 skip |=
5455 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5456 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5457 }
5458 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5459 skip |=
5460 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5461 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5462 }
5463 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5464 skip |=
5465 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5466 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005467 }
5468 return skip;
5469}
5470
5471bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5472 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5473 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5474 bool skip = false;
5475 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5476 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5477 skip |= LogError(
5478 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5479 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5480 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5481 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005482 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5483 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005484 skip |=
5485 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5486 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5487 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5488 }
5489 return false;
5490}
5491
5492bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5493 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5494 bool skip = false;
5495 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5496 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5497 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5498 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5499 }
5500 return skip;
5501}
5502
5503bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5504 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5505 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5506 bool skip = false;
5507 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5508 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005509 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5510 "vkBuildAccelerationStructureKHR: The "
5511 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5512 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005513 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005514 return skip;
5515}
sourav parmara24fb7b2020-05-26 10:50:04 -07005516bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5517 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5518 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5519 bool skip = false;
5520 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005521 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5522 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005523 skip |=
5524 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5525 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5526 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5527 }
5528 }
5529 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005530}