blob: da48a8c25ce2af1ad59b8c580a2ef2565c8fbebd [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
300
Locke77fad1c2019-04-16 13:09:03 -0600301 auto vertex_attribute_divisor_features =
302 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
303 if (vertex_attribute_divisor_features) {
304 bool extension_found = false;
305 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
306 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
307 VK_MAX_EXTENSION_NAME_SIZE)) {
308 extension_found = true;
309 break;
310 }
311 }
312 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700313 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
314 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
315 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600316 }
317 }
318
Tony-LunarG28017bc2020-01-23 14:40:25 -0700319 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
320 if (vulkan_11_features) {
321 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
322 while (current) {
323 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
324 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
325 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
326 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
327 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
328 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700329 skip |= LogError(
330 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700331 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
332 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
333 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
334 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
335 break;
336 }
337 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
338 }
339 }
340
341 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
342 if (vulkan_12_features) {
343 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
344 while (current) {
345 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
346 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
347 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
348 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
349 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
350 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
351 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700358 skip |= LogError(
359 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700360 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
361 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
362 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
363 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
364 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
365 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
366 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
367 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
368 break;
369 }
370 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
371 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700372 // Check features are enabled if matching extension is passed in as well
373 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
374 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
375 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
376 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
377 skip |= LogError(
378 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
379 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
380 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
381 }
382 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
383 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
384 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
386 "is not VK_TRUE.",
387 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
388 }
389 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
390 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
391 skip |= LogError(
392 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
393 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
394 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
395 }
396 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
397 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
398 skip |= LogError(
399 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
400 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
401 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
402 }
403 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
404 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
405 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
406 skip |=
407 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
408 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
409 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
410 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
411 }
412 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700413 }
414
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600415 // Validate pCreateInfo->pQueueCreateInfos
416 if (pCreateInfo->pQueueCreateInfos) {
417 std::unordered_set<uint32_t> set;
418
419 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700420 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
421 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600422 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700423 skip |=
424 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
425 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
426 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
427 "index value.",
428 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600429 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700430 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
432 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
433 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600434 } else {
435 set.insert(requested_queue_family);
436 }
437
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700438 if (queue_create_info.pQueuePriorities != nullptr) {
439 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
440 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600441 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700442 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
443 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
444 "] (=%f) is not between 0 and 1 (inclusive).",
445 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600446 }
447 }
448 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700449
450 // Need to know if protectedMemory feature is passed in preCall to creating the device
451 VkBool32 protectedMemory = VK_FALSE;
452 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
453 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
454 if (protected_features) {
455 protectedMemory = protected_features->protectedMemory;
456 } else if (vulkan_11_features) {
457 protectedMemory = vulkan_11_features->protectedMemory;
458 }
459 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
460 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
461 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
462 "protectedMemory feature being set as well.");
463 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600464 }
465 }
466
467 return skip;
468}
469
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500470bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700471 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700472 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
473 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
474 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600475 }
476
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700477 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600478}
479
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700480bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500481 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100482 bool skip = false;
483
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600484 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700485 skip |=
486 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600487
488 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
489 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
490 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
491 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700492 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
493 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
494 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600495 }
496
497 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
498 // queueFamilyIndexCount uint32_t values
499 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700500 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
501 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
502 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
503 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600504 }
505 }
506
507 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
508 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
509 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
510 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700511 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
512 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
513 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600514 }
515 }
516
517 return skip;
518}
519
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700520bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500521 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600522 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523
524 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600525 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
526 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
527 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
528 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700529 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
530 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
531 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532 }
533
534 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
535 // queueFamilyIndexCount uint32_t values
536 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
538 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
540 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600541 }
542 }
543
Dave Houlton413a6782018-05-22 13:01:54 -0600544 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600546 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700547 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600548 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700549 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600550
Dave Houlton413a6782018-05-22 13:01:54 -0600551 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700552 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600553 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700554 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555
Dave Houlton130c0212018-01-29 13:39:56 -0700556 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700557 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
558 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(
560 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600561 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
562 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700563 }
564
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600565 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100566 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
567 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700568 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
569 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
570 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600571 }
572
573 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100574 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
575 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
577 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
578 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
579 ") are not equal.",
580 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100581 }
582
583 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700584 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
585 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
586 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
587 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100588 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600589 }
590
591 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 skip |= LogError(
593 device, "VUID-VkImageCreateInfo-imageType-00957",
594 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595 }
596 }
597
Dave Houlton130c0212018-01-29 13:39:56 -0700598 // 3D image may have only 1 layer
599 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700600 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
601 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700602 }
603
604 // If multi-sample, validate type, usage, tiling and mip levels.
605 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
606 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600607 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700608 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
609 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700610 }
611
612 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
613 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
614 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
615 // At least one of the legal attachment bits must be set
616 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700617 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
618 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700619 }
620 // No flags other than the legal attachment bits may be set
621 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
622 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700623 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
624 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700625 }
626 }
627
Jeff Bolzef40fec2018-09-01 22:04:34 -0500628 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600629 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500630 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600631 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
632 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500633 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600634 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700635 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
636 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
637 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600638 }
639
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600640 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700641 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
642 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
643 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600644 }
645
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700646 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700647 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
648 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
649 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100650 }
651
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600652 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
653 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
654 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
655 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700656 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
657 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
658 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600659 }
660
661 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
662 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
663 // Linear tiling is unsupported
664 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700665 skip |= LogError(device, kVUID_PVError_InvalidUsage,
666 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
667 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600668 }
669
670 // Sparse 1D image isn't valid
671 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700672 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
673 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 }
675
676 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700677 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700678 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
679 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
680 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600681 }
682
683 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700684 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700685 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
686 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
687 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600688 }
689
690 // Multi-sample 2D image when device doesn't support it
691 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700692 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600693 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
695 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
696 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700697 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600698 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
700 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
701 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700702 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700704 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
705 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
706 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700707 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600708 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700709 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
710 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
711 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600712 }
713 }
714 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500715
Jeff Bolz9af91c52018-09-01 21:53:57 -0500716 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
717 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700718 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
719 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
720 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500721 }
722 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
724 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
725 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500726 }
727 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700728 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
729 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
730 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500731 }
732 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500733
734 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600735 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700736 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
737 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
738 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500739 }
740
Dave Houlton142c4cb2018-10-17 15:04:41 -0600741 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700742 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
743 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
744 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
745 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500746 }
747
Dave Houlton142c4cb2018-10-17 15:04:41 -0600748 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
750 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
751 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
752 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500753 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600754 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700755 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
756 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
757 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
758 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500759 }
760 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500761
sfricke-samsung8f658d42020-05-03 20:12:24 -0700762 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
763 (FormatHasDepth(pCreateInfo->format) == false)) {
764 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
765 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
766 "format must be a depth or depth/stencil format.");
767 }
768
Andrew Fobel3abeb992020-01-20 16:33:22 -0500769 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
770 if (image_stencil_struct != nullptr) {
771 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
772 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
773 // No flags other than the legal attachment bits may be set
774 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
775 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700776 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
777 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
778 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
779 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500780 }
781 }
782
783 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
784 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
785 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
786 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
788 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
789 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
790 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500791 }
792
793 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
794 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700795 LogError(device, "VUID-VkImageCreateInfo-format-02537",
796 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
797 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
798 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500799 }
800 }
801
802 if (!physical_device_features.shaderStorageImageMultisample &&
803 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
804 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
805 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700806 LogError(device, "VUID-VkImageCreateInfo-format-02538",
807 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
808 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
809 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500810 }
811
812 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
813 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700814 skip |= LogError(
815 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500816 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
817 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
818 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
819 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
820 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(
822 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500823 "vkCreateImage(): Depth-stencil image in which usage does not include "
824 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
825 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
826 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
827 }
828
829 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
830 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700831 skip |= LogError(
832 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500833 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
834 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
835 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
836 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
837 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700838 skip |= LogError(
839 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500840 "vkCreateImage(): Depth-stencil image in which usage does not include "
841 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
842 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
843 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
844 }
845 }
846 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700847
848 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
849 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
850 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
851 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
852 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
853 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700854
855 if (device_extensions.vk_ext_image_drm_format_modifier) {
856 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
857 const auto drm_format_mod_explict =
858 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
859 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
860 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
861 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
862 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
863 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
864 "either VkImageDrmFormatModifierListCreateInfoEXT or "
865 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
866 }
867 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
868 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
869 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
870 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
871 "in the pNext chain");
872 }
873 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200874
875 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
876 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
877 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
878 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
879 "imageType must be VK_IMAGE_TYPE_2D.");
880 }
881 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
882 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
883 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
884 "samples must be VK_SAMPLE_COUNT_1_BIT.");
885 }
886 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
887 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
888 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
889 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
890 }
891 }
892 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
893 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
894 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
895 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
896 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
897 }
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
900 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
902 }
903 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
904 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
905 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
906 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
907 }
908 if (pCreateInfo->mipLevels != 1) {
909 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
910 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
911 pCreateInfo->mipLevels);
912 }
913 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600914 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500915
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600916 return skip;
917}
918
Jeff Bolz99e3f632020-03-24 22:59:22 -0500919bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
920 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
921 bool skip = false;
922
923 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700924 // Validate feature set if using CUBE_ARRAY
925 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
926 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
927 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
928 "enabling the imageCubeArray feature.");
929 }
930
Jeff Bolz99e3f632020-03-24 22:59:22 -0500931 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
932 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
933 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700934 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500935 pCreateInfo->subresourceRange.layerCount);
936 }
937 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700938 skip |= LogError(
939 device, "VUID-VkImageViewCreateInfo-viewType-02961",
940 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
941 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500942 }
943 }
944 }
945 return skip;
946}
947
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600948bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700949 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100950 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100951
952 // Note: for numerical correctness
953 // - float comparisons should expect NaN (comparison always false).
954 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
955
956 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700957 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100958 if (v1_f <= 0.0f) return true;
959
960 float intpart;
961 const float fract = modff(v1_f, &intpart);
962
963 assert(std::numeric_limits<float>::radix == 2);
964 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
965 if (intpart >= u32_max_plus1) return false;
966
967 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
968 if (v1_u32 < v2_u32)
969 return true;
970 else if (v1_u32 == v2_u32 && fract == 0.0f)
971 return true;
972 else
973 return false;
974 };
975
976 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
977 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
978 return (v1_f <= v2_f);
979 };
980
981 // width
982 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700983 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +0100984
985 if (!(viewport.width > 0.0f)) {
986 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700987 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
988 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100989 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
990 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700991 skip |= LogError(object, "VUID-VkViewport-width-01771",
992 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
993 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100994 } else if (!f_lte_u32_exact(viewport.width, max_w) && f_lte_u32_direct(viewport.width, max_w)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700995 skip |= LogWarning(object, kVUID_PVError_NONE,
996 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
997 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
998 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +0100999 }
1000
1001 // height
1002 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001003 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001004 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001005
1006 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1007 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001008 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1009 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001010 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1011 height_healthy = false;
1012
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 skip |= LogError(object, "VUID-VkViewport-height-01773",
1014 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1015 ").",
1016 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001017 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1018 height_healthy = false;
1019
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001020 skip |= LogWarning(
1021 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001022 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001023 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001024 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001025 }
1026
1027 // x
1028 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001029 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001030 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001031 skip |= LogError(object, "VUID-VkViewport-x-01774",
1032 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1033 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001034 }
1035
1036 // x + width
1037 if (x_healthy && width_healthy) {
1038 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001039 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001040 skip |= LogError(
1041 object, "VUID-VkViewport-x-01232",
1042 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1043 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1044 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001045 }
1046 }
1047
1048 // y
1049 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001050 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001051 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001052 skip |= LogError(object, "VUID-VkViewport-y-01775",
1053 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1054 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001055 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001056 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001057 skip |= LogError(object, "VUID-VkViewport-y-01776",
1058 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1059 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001060 }
1061
1062 // y + height
1063 if (y_healthy && height_healthy) {
1064 const float boundary = viewport.y + viewport.height;
1065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001066 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001067 skip |= LogError(object, "VUID-VkViewport-y-01233",
1068 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1069 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1070 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001071 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001072 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001073 LogError(object, "VUID-VkViewport-y-01777",
1074 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1075 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1076 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001077 }
1078 }
1079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001080 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001081 // minDepth
1082 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001083 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001084
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001085 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1086 "[0.0, 1.0] range.",
1087 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001088 }
1089
1090 // maxDepth
1091 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001092 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001093
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001094 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1095 "[0.0, 1.0] range.",
1096 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001097 }
1098 }
1099
1100 return skip;
1101}
1102
Dave Houlton142c4cb2018-10-17 15:04:41 -06001103struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001104 VkShadingRatePaletteEntryNV shadingRate;
1105 uint32_t width;
1106 uint32_t height;
1107};
1108
1109// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001110static SampleOrderInfo sampleOrderInfos[] = {
1111 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1112 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1113 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1114 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1115 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1116 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001117};
1118
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001119bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001120 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001121
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001122 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001123 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001124 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001125 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001126 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001127 break;
1128 }
1129 }
1130
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001131 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001132 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1133 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1134 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001135 return skip;
1136 }
1137
Dave Houlton142c4cb2018-10-17 15:04:41 -06001138 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001139 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001140 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1141 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1142 ") must "
1143 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1144 "is set in framebufferNoAttachmentsSampleCounts.",
1145 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001146 }
1147
Jeff Bolz9af91c52018-09-01 21:53:57 -05001148 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001149 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1150 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1151 ") must "
1152 "be equal to the product of sampleCount (=%" PRIu32
1153 "), the fragment width for shadingRate "
1154 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1155 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001156 }
1157
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001158 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001159 skip |= LogError(
1160 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001161 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1162 ") must "
1163 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001164 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001165 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001166
1167 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001168 // the first width*height*sampleCount bits to all be set. Note: There is no
1169 // guarantee that 64 bits is enough, but practically it's unlikely for an
1170 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001171 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001172 uint64_t sampleLocationsMask = 0;
1173 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1174 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1175 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001176 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1177 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001178 }
1179 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001180 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1181 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001182 }
1183 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001184 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1185 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001186 }
1187 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1188 sampleLocationsMask |= 1ULL << idx;
1189 }
1190
1191 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1192 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001193 skip |= LogError(
1194 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001195 "The array pSampleLocations must contain exactly one entry for "
1196 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001197 }
1198
1199 return skip;
1200}
1201
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001202bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1203 uint32_t createInfoCount,
1204 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1205 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001206 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001207 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001208
1209 if (pCreateInfos != nullptr) {
1210 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001211 bool has_dynamic_viewport = false;
1212 bool has_dynamic_scissor = false;
1213 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001214 bool has_dynamic_depth_bias = false;
1215 bool has_dynamic_blend_constant = false;
1216 bool has_dynamic_depth_bounds = false;
1217 bool has_dynamic_stencil_compare = false;
1218 bool has_dynamic_stencil_write = false;
1219 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001220 bool has_dynamic_viewport_w_scaling_nv = false;
1221 bool has_dynamic_discard_rectangle_ext = false;
1222 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001223 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001224 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001225 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001226 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001227 if (pCreateInfos[i].pDynamicState != nullptr) {
1228 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1229 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1230 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001231 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1232 if (has_dynamic_viewport == true) {
1233 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1234 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1235 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1236 i);
1237 }
1238 has_dynamic_viewport = true;
1239 }
1240 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1241 if (has_dynamic_scissor == true) {
1242 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1243 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1244 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1245 i);
1246 }
1247 has_dynamic_scissor = true;
1248 }
1249 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1250 if (has_dynamic_line_width == true) {
1251 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1252 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1253 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1254 i);
1255 }
1256 has_dynamic_line_width = true;
1257 }
1258 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1259 if (has_dynamic_depth_bias == true) {
1260 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1261 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1262 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1263 i);
1264 }
1265 has_dynamic_depth_bias = true;
1266 }
1267 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1268 if (has_dynamic_blend_constant == true) {
1269 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1270 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1271 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1272 i);
1273 }
1274 has_dynamic_blend_constant = true;
1275 }
1276 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1277 if (has_dynamic_depth_bounds == true) {
1278 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1279 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1280 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1281 i);
1282 }
1283 has_dynamic_depth_bounds = true;
1284 }
1285 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1286 if (has_dynamic_stencil_compare == true) {
1287 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1288 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1289 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1290 i);
1291 }
1292 has_dynamic_stencil_compare = true;
1293 }
1294 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1295 if (has_dynamic_stencil_write == true) {
1296 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1297 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1298 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1299 i);
1300 }
1301 has_dynamic_stencil_write = true;
1302 }
1303 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1304 if (has_dynamic_stencil_reference == true) {
1305 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1306 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1307 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1308 i);
1309 }
1310 has_dynamic_stencil_reference = true;
1311 }
1312 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1313 if (has_dynamic_viewport_w_scaling_nv == true) {
1314 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1315 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1316 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1317 i);
1318 }
1319 has_dynamic_viewport_w_scaling_nv = true;
1320 }
1321 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1322 if (has_dynamic_discard_rectangle_ext == true) {
1323 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1324 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1325 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1326 i);
1327 }
1328 has_dynamic_discard_rectangle_ext = true;
1329 }
1330 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1331 if (has_dynamic_sample_locations_ext == true) {
1332 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1333 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1334 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1335 i);
1336 }
1337 has_dynamic_sample_locations_ext = true;
1338 }
1339 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1340 if (has_dynamic_exclusive_scissor_nv == true) {
1341 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1342 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1343 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1344 i);
1345 }
1346 has_dynamic_exclusive_scissor_nv = true;
1347 }
1348 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1349 if (has_dynamic_shading_rate_palette_nv == true) {
1350 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1351 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1352 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1353 i);
1354 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001355 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001356 }
1357 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1358 if (has_dynamic_viewport_course_sample_order_nv == true) {
1359 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1360 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1361 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1362 i);
1363 }
1364 has_dynamic_viewport_course_sample_order_nv = true;
1365 }
1366 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1367 if (has_dynamic_line_stipple == true) {
1368 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1369 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1370 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1371 i);
1372 }
1373 has_dynamic_line_stipple = true;
1374 }
Petr Kraus299ba622017-11-24 03:09:03 +01001375 }
1376 }
1377
Peter Chen85366392019-05-14 15:20:11 -04001378 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1379 if ((feedback_struct != nullptr) &&
1380 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001381 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1382 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1383 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1384 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1385 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001386 }
1387
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001388 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001389
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001390 // Collect active stages and other information
1391 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001392 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001393 bool has_eval = false;
1394 bool has_control = false;
1395 if (pCreateInfos[i].pStages != nullptr) {
1396 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1397 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1398
1399 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1400 has_control = true;
1401 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1402 has_eval = true;
1403 }
1404
1405 skip |= validate_string(
1406 "vkCreateGraphicsPipelines",
1407 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1408 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1409 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001410 }
1411
1412 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1413 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1414 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1415 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1416 pCreateInfos[i].pTessellationState,
1417 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1418 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1419
1420 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1421 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1422
1423 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1424 "VkPipelineTessellationDomainOriginStateCreateInfo",
1425 pCreateInfos[i].pTessellationState->pNext,
1426 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1427 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001428 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1429 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001430
1431 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1432 pCreateInfos[i].pTessellationState->flags,
1433 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1434 }
1435
1436 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1437 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1438 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1439 pCreateInfos[i].pInputAssemblyState,
1440 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1441 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1442
1443 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1444 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001445 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001446
1447 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1448 pCreateInfos[i].pInputAssemblyState->flags,
1449 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1450
1451 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1452 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1453 pCreateInfos[i].pInputAssemblyState->topology,
1454 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1455
1456 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1457 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1458 }
1459
1460 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001461 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001462
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001463 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001464 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1465 "vkCreateGraphicsPipelines: pararameter "
1466 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1467 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001468 }
1469
1470 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1471 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1472 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1473 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1474 pCreateInfos[i].pVertexInputState->pNext, 1,
1475 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001476 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1477 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001478 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1479 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001480 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001481 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1482 skip |=
1483 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1484 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1485 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1486 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1487 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1488
1489 skip |= validate_array(
1490 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1491 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1492 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1493 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1494
1495 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1496 for (uint32_t vertexBindingDescriptionIndex = 0;
1497 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1498 ++vertexBindingDescriptionIndex) {
1499 skip |= validate_ranged_enum(
1500 "vkCreateGraphicsPipelines",
1501 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1502 AllVkVertexInputRateEnums,
1503 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1504 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1505 }
1506 }
1507
1508 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1509 for (uint32_t vertexAttributeDescriptionIndex = 0;
1510 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1511 ++vertexAttributeDescriptionIndex) {
1512 skip |= validate_ranged_enum(
1513 "vkCreateGraphicsPipelines",
1514 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1515 AllVkFormatEnums,
1516 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1517 "VUID-VkVertexInputAttributeDescription-format-parameter");
1518 }
1519 }
1520
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001521 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001522 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1523 "vkCreateGraphicsPipelines: pararameter "
1524 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1525 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1526 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001527 }
1528
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001529 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001530 skip |=
1531 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1532 "vkCreateGraphicsPipelines: pararameter "
1533 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1534 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1535 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001536 }
1537
1538 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001539 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1540 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001541 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1542 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001543 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1544 "vkCreateGraphicsPipelines: parameter "
1545 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1546 "(%" PRIu32 ") is not distinct.",
1547 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001548 }
1549 vertex_bindings.insert(vertex_bind_desc.binding);
1550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001551 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001552 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1553 "vkCreateGraphicsPipelines: parameter "
1554 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1555 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1556 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001557 }
1558
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001559 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001560 skip |=
1561 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1562 "vkCreateGraphicsPipelines: parameter "
1563 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1564 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1565 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001566 }
1567 }
1568
Peter Kohautc7d9d392018-07-15 00:34:07 +02001569 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001570 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1571 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001572 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1573 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001574 skip |= LogError(
1575 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001576 "vkCreateGraphicsPipelines: parameter "
1577 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1578 i, d, vertex_attrib_desc.location);
1579 }
1580 attribute_locations.insert(vertex_attrib_desc.location);
1581
1582 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1583 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(
1585 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001586 "vkCreateGraphicsPipelines: parameter "
1587 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1588 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1589 i, d, vertex_attrib_desc.binding, i);
1590 }
1591
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001592 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001593 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1594 "vkCreateGraphicsPipelines: parameter "
1595 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1596 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1597 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001598 }
1599
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001600 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001601 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1602 "vkCreateGraphicsPipelines: parameter "
1603 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1604 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1605 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001606 }
1607
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001608 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001609 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1610 "vkCreateGraphicsPipelines: parameter "
1611 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1612 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1613 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001614 }
1615 }
1616 }
1617
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001618 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1619 if (has_control && has_eval) {
1620 if (pCreateInfos[i].pTessellationState == nullptr) {
1621 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1622 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1623 "shader stage and a tessellation evaluation shader stage, "
1624 "pCreateInfos[%d].pTessellationState must not be NULL.",
1625 i, i);
1626 } else {
1627 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1628 skip |= validate_struct_pnext(
1629 "vkCreateGraphicsPipelines",
1630 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1631 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1632 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1633 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001634
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001635 skip |= validate_reserved_flags(
1636 "vkCreateGraphicsPipelines",
1637 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1638 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001639
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001640 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1641 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1642 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1643 "vkCreateGraphicsPipelines: invalid parameter "
1644 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1645 "should be >0 and <=%u.",
1646 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1647 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001648 }
1649 }
1650 }
1651
1652 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1653 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1654 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1655 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001656 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1657 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1658 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1659 "].pViewportState (=NULL) is not a valid pointer.",
1660 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001661 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001662 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1663
1664 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001665 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1666 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1667 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1668 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001669 }
1670
Petr Krausa6103552017-11-16 21:21:58 +01001671 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1672 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001673 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1674 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001675 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1676 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001677 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001678 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001679 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001680 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001681 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001682 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1683 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001684 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001685 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1686 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001687
1688 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001689 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001690 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001691 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001692
Dave Houlton142c4cb2018-10-17 15:04:41 -06001693 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1694 pCreateInfos[i].pViewportState->pNext);
1695 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1696 pCreateInfos[i].pViewportState->pNext);
1697 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1698 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001699 const auto vp_swizzle_struct =
1700 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001701 const auto vp_w_scaling_struct =
1702 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001703
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001704 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001705 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001706 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1707 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1708 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1709 ") is not 1.",
1710 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001711 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001712
Petr Krausa6103552017-11-16 21:21:58 +01001713 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001714 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1715 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1716 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1717 ") is not 1.",
1718 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001719 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001720
Dave Houlton142c4cb2018-10-17 15:04:41 -06001721 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1722 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001723 skip |= LogError(
1724 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1725 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1726 "disabled, but pCreateInfos[%" PRIu32
1727 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1728 ") is not 1.",
1729 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001730 }
1731
Jeff Bolz9af91c52018-09-01 21:53:57 -05001732 if (shading_rate_image_struct &&
1733 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001734 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1735 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1736 "disabled, but pCreateInfos[%" PRIu32
1737 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1738 ") is neither 0 nor 1.",
1739 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001740 }
1741
Petr Krausa6103552017-11-16 21:21:58 +01001742 } else { // multiViewport enabled
1743 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001744 skip |= LogError(
1745 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001746 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001747 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001748 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1749 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1750 "].pViewportState->viewportCount (=%" PRIu32
1751 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1752 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001753 }
Petr Krausa6103552017-11-16 21:21:58 +01001754
1755 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001756 skip |= LogError(
1757 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001758 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001759 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001760 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1761 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1762 "].pViewportState->scissorCount (=%" PRIu32
1763 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1764 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001765 }
1766 }
1767
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001768 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001769 skip |=
1770 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1771 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1772 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1773 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001774 }
1775
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001776 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001777 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1778 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1779 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1780 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1781 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001782 }
1783
Petr Krausa6103552017-11-16 21:21:58 +01001784 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001785 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1786 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1787 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1788 "].pViewportState->viewportCount (=%" PRIu32 ").",
1789 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001790 }
1791
Dave Houlton142c4cb2018-10-17 15:04:41 -06001792 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001793 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001794 skip |=
1795 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1796 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1797 ") must be zero or identical to pCreateInfos[%" PRIu32
1798 "].pViewportState->viewportCount (=%" PRIu32 ").",
1799 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001800 }
1801
Dave Houlton142c4cb2018-10-17 15:04:41 -06001802 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001803 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001804 skip |= LogError(
1805 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001806 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1807 "] "
1808 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1809 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1810 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001811 }
1812
Petr Krausa6103552017-11-16 21:21:58 +01001813 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001814 skip |= LogError(
1815 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001816 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1817 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001818 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1819 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001820 }
1821
1822 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001823 skip |= LogError(
1824 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001825 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1826 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001827 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1828 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001829 }
1830
Jeff Bolz3e71f782018-08-29 23:15:45 -05001831 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001832 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1833 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1834 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001835 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1836 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1837 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1838 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1839 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001840 }
1841
Jeff Bolz9af91c52018-09-01 21:53:57 -05001842 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001843 shading_rate_image_struct->viewportCount > 0 &&
1844 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001845 skip |= LogError(
1846 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001847 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001848 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1849 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001850 i, i);
1851 }
1852
Chris Mayer328d8212018-12-11 14:16:18 +01001853 if (vp_swizzle_struct) {
1854 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001855 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1856 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1857 " does "
1858 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1859 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001860 }
1861 }
1862
Petr Krausb3fcdb42018-01-09 22:09:09 +01001863 // validate the VkViewports
1864 if (!has_dynamic_viewport && viewport_state.pViewports) {
1865 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1866 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001867 const char *fn_name = "vkCreateGraphicsPipelines";
1868 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1869 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1870 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001871 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001872 }
1873 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001874
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001875 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001876 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1877 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1878 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1879 "VK_NV_clip_space_w_scaling extension is not enabled.",
1880 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001881 }
1882
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001883 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001884 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1885 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1886 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1887 "VK_EXT_discard_rectangles extension is not enabled.",
1888 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001889 }
1890
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001891 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001892 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1893 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1894 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1895 "VK_EXT_sample_locations extension is not enabled.",
1896 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001897 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001898
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001899 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001900 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1901 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1902 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1903 "VK_NV_scissor_exclusive extension is not enabled.",
1904 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001905 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001906
1907 if (coarse_sample_order_struct &&
1908 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1909 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001910 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1911 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1912 "] "
1913 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1914 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1915 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001916 }
1917
1918 if (coarse_sample_order_struct) {
1919 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001920 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001921 }
1922 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001923
1924 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1925 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001926 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1927 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1928 "] "
1929 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1930 ") "
1931 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1932 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001933 }
1934 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001935 skip |= LogError(
1936 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001937 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1938 "] "
1939 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1940 i);
1941 }
1942 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001943 }
1944
1945 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001946 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1947 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1948 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1949 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001950 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001951 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1952 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1953 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001954 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001955 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001956 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001957 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001958 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001959 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001960 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001961 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1962 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001963
1964 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001965 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001966 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001967 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001968
1969 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001970 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1972 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1973
1974 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001975 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001976 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1977 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00001978 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06001979 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001980
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001981 skip |= validate_flags(
1982 "vkCreateGraphicsPipelines",
1983 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1984 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02001985 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001987 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001989 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
1990 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
1991
1992 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001993 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001994 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
1995 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
1996
1997 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001998 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
1999 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2000 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2001 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002 }
John Zulauf7acac592017-11-06 11:15:53 -07002003 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002004 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002005 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2006 "vkCreateGraphicsPipelines(): parameter "
2007 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2008 i);
John Zulauf7acac592017-11-06 11:15:53 -07002009 }
2010 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2011 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2012 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002013 skip |= LogError(
2014 device,
2015
Dave Houlton413a6782018-05-22 13:01:54 -06002016 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002017 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002018 }
2019 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002020
2021 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2022 pCreateInfos[i].pRasterizationState->pNext);
2023
2024 if (line_state) {
2025 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2026 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2027 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2028 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002029 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2030 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2031 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2032 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002033 }
2034 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2035 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002036 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2037 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2038 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2039 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002040 }
2041 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2042 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002043 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2044 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2045 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2046 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002047 }
2048 }
2049 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2050 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2051 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002052 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2053 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2054 "range [1,256].",
2055 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002056 }
2057 }
2058 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002059 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002060 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2061 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002062 skip |=
2063 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2064 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2065 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2066 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002067 }
2068 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2069 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002070 skip |=
2071 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2072 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2073 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2074 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002075 }
2076 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2077 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002078 skip |=
2079 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2080 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2081 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2082 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002083 }
2084 if (line_state->stippledLineEnable) {
2085 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2086 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002087 skip |=
2088 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2089 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2090 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2091 "stippledRectangularLines feature.",
2092 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002093 }
2094 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2095 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002096 skip |=
2097 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2098 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2099 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2100 "stippledBresenhamLines feature.",
2101 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002102 }
2103 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2104 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002105 skip |=
2106 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2107 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2108 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2109 "stippledSmoothLines feature.",
2110 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002111 }
2112 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2113 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002114 skip |=
2115 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2116 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2117 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2118 "stippledRectangularLines and strictLines features.",
2119 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002120 }
2121 }
2122 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002123 }
2124
Petr Krause91f7a12017-12-14 20:57:36 +01002125 bool uses_color_attachment = false;
2126 bool uses_depthstencil_attachment = false;
2127 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002128 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002129 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2130 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002131 const auto &subpasses_uses = subpasses_uses_it->second;
2132 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2133 uses_color_attachment = true;
2134 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2135 uses_depthstencil_attachment = true;
2136 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002137 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002138 }
2139
2140 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002141 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002142 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002143 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002144 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002145 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002146
2147 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002148 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002149 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002150 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002151
2152 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002153 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002154 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2155 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2156
2157 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002158 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002159 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2160 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2161
2162 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002163 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002164 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2165 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002166 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002167
2168 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002169 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002170 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2171 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2172
2173 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002174 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002175 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2176 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2177
2178 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002179 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002180 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2181 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002182 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002183
2184 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002185 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002186 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2187 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002191 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2193 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002194 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002195
2196 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002197 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002198 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2199 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002200 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002201
2202 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002203 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002204 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2205 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002206 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002207
2208 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002209 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002210 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2211 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002212 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213
2214 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2217 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002218 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002219
2220 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002221 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002222 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2223 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002224 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002225
2226 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002227 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2228 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2229 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2230 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002231 }
2232 }
2233
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002234 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2235 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2236
Petr Krause91f7a12017-12-14 20:57:36 +01002237 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002238 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2239 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2240 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2241 pCreateInfos[i].pColorBlendState,
2242 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2243 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2244
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002246 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002247 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2248 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2249 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002250 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002251 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2252 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253
2254 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002255 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002256 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002257 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002258
2259 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002260 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002261 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2262 pCreateInfos[i].pColorBlendState->logicOpEnable);
2263
2264 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002265 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2267 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002268 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002269 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270
2271 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2272 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2273 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002274 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2276 ParameterName::IndexVector{i, attachmentIndex}),
2277 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2278
2279 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002280 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2282 ParameterName::IndexVector{i, attachmentIndex}),
2283 "VkBlendFactor", AllVkBlendFactorEnums,
2284 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002285 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002286
2287 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002288 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2290 ParameterName::IndexVector{i, attachmentIndex}),
2291 "VkBlendFactor", AllVkBlendFactorEnums,
2292 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002293 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002294
2295 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002296 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2298 ParameterName::IndexVector{i, attachmentIndex}),
2299 "VkBlendOp", AllVkBlendOpEnums,
2300 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002301 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002302
2303 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002304 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002305 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2306 ParameterName::IndexVector{i, attachmentIndex}),
2307 "VkBlendFactor", AllVkBlendFactorEnums,
2308 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002309 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002310
2311 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002312 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002313 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2314 ParameterName::IndexVector{i, attachmentIndex}),
2315 "VkBlendFactor", AllVkBlendFactorEnums,
2316 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002317 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318
2319 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002320 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002321 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2322 ParameterName::IndexVector{i, attachmentIndex}),
2323 "VkBlendOp", AllVkBlendOpEnums,
2324 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002325 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002326
2327 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002328 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002329 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2330 ParameterName::IndexVector{i, attachmentIndex}),
2331 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2332 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002333 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002334 }
2335 }
2336
2337 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002338 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2339 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2340 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2341 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002342 }
2343
2344 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2345 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2346 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002347 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002349 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2350 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 }
2352 }
2353 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002354
Petr Kraus9752aae2017-11-24 03:05:50 +01002355 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2356 if (pCreateInfos[i].basePipelineIndex != -1) {
2357 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002358 skip |=
2359 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
2360 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineHandle, must be "
2361 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
2362 "and pCreateInfos->basePipelineIndex is not -1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002363 }
2364 }
2365
Petr Kraus9752aae2017-11-24 03:05:50 +01002366 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2367 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002368 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
2369 "vkCreateGraphicsPipelines parameter, pCreateInfos->basePipelineIndex, must be -1 if "
2370 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
2371 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002372 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002373 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002374 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002375 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2376 "vkCreateGraphicsPipelines parameter pCreateInfos->basePipelineIndex (%d) must be a valid"
2377 "index into the pCreateInfos array, of size %d.",
2378 pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002379 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002380 }
2381 }
2382
sfricke-samsung898cf222020-05-15 23:10:19 -07002383 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2384 skip |= LogError(
2385 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2386 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2387 i);
2388 }
2389
Petr Kraus9752aae2017-11-24 03:05:50 +01002390 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002391 if (!device_extensions.vk_nv_fill_rectangle) {
2392 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2393 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002394 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2395 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2396 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2397 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002398 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2399 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2401 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2402 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2403 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002404 }
2405 } else {
2406 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2407 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2408 (physical_device_features.fillModeNonSolid == false)) {
2409 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002410 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2411 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2412 "pCreateInfos->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2413 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002414 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002415 }
Petr Kraus299ba622017-11-24 03:09:03 +01002416
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002417 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002418 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2420 "The line width state is static (pCreateInfos[%" PRIu32
2421 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2422 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2423 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2424 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002425 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002426 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002427 }
2428 }
2429
2430 return skip;
2431}
2432
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002433bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2434 uint32_t createInfoCount,
2435 const VkComputePipelineCreateInfo *pCreateInfos,
2436 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002437 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002438 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002439 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002440 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002441 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002442 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002443 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2444 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002445 skip |=
2446 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2447 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2448 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2449 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002450 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002451
2452 // Make sure compute stage is selected
2453 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002454 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2455 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2456 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002457 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002458 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002459 return skip;
2460}
2461
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002462bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002463 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002464 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465
2466 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467 const auto &features = physical_device_features;
2468 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002469
John Zulauf71968502017-10-26 13:51:15 -06002470 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2471 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002472 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2473 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2474 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2475 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002476 }
2477
2478 // Anistropy cannot be enabled in sampler unless enabled as a feature
2479 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002480 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2481 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2482 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002483 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002484 }
John Zulauf71968502017-10-26 13:51:15 -06002485
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002486 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2487 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002488 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2489 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2490 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2491 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002492 }
2493 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002494 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2495 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2496 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2497 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002498 }
2499 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002500 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2501 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2502 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2503 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002504 }
2505 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2506 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2507 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2508 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002509 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2510 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2511 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2512 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2513 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2514 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002515 }
2516 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002517 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2518 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2519 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002520 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002521 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002522 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2523 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2524 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002525 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526 }
2527
2528 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2529 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002530 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2531 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002532 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2533 if (sampler_reduction != nullptr) {
2534 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2535 skip |= LogError(
2536 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2537 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2538 }
2539 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002540 }
2541
2542 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2543 // valid VkBorderColor value
2544 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2545 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2546 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002547 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2548 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002549 }
2550
2551 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2552 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002553 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002554 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2555 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2556 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002557 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002558 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2559 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2560 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002561 }
John Zulauf275805c2017-10-26 15:34:49 -06002562
2563 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002564 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002565 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2566 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002567 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2568 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2569 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002570 }
2571 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002572
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002573 // Check for valid Lod range
2574 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002575 skip |=
2576 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2577 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002578 }
2579
2580 // Check mipLodBias to device limit
2581 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002582 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2583 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2584 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002585 }
2586
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002587 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2588 if (sampler_conversion != nullptr) {
2589 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2590 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2591 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2592 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002593 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002594 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002595 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2596 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2597 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2598 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2599 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2600 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2601 }
2602 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002603
2604 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2605 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2606 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2607 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2608 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2609 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2610 }
2611 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2612 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2613 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2614 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2615 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2616 }
2617 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2618 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2619 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2620 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2621 pCreateInfo->minLod, pCreateInfo->maxLod);
2622 }
2623 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2624 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2625 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2626 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2627 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2628 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2629 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2630 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2631 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2632 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2633 }
2634 if (pCreateInfo->anisotropyEnable) {
2635 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2636 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2637 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2638 }
2639 if (pCreateInfo->compareEnable) {
2640 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2641 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2642 "pCreateInfo->compareEnable must be VK_FALSE");
2643 }
2644 if (pCreateInfo->unnormalizedCoordinates) {
2645 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2646 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2647 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2648 }
2649 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 }
2651
Tony-LunarG7337b312020-04-15 16:40:25 -06002652 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2653 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2654 if (!device_extensions.vk_ext_custom_border_color) {
2655 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2656 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2657 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2658 }
2659 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2660 if (!custom_create_info) {
2661 skip |=
2662 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2663 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2664 "struct in pNext chain.\n",
2665 string_VkBorderColor(pCreateInfo->borderColor));
2666 } else {
2667 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2668 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2669 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2670 !FormatIsSampledFloat(custom_create_info->format)))) {
2671 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2672 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2673 "whose type does not match\n",
2674 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2675 ;
2676 }
2677 }
2678 }
2679
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002680 return skip;
2681}
2682
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002683bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2684 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2685 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002686 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002687 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002688
2689 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2690 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2691 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2692 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002693 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2694 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2695 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2696 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2697 ++descriptor_index) {
2698 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002699 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002700 "vkCreateDescriptorSetLayout: required parameter "
2701 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2702 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002703 }
2704 }
2705 }
2706
2707 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2708 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2709 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002710 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2711 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2712 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2713 "values.",
2714 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002716
2717 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2718 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2719 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2720 skip |=
2721 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2722 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2723 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2724 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2725 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2726 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002727 }
2728 }
2729 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730 return skip;
2731}
2732
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002733bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2734 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002735 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002736 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2737 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2738 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002739 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2740 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002741}
2742
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002743bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2744 const VkWriteDescriptorSet *pDescriptorWrites,
2745 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002747
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 if (pDescriptorWrites != NULL) {
2749 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2750 // descriptorCount must be greater than 0
2751 if (pDescriptorWrites[i].descriptorCount == 0) {
2752 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002753 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2754 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755 }
2756
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002757 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2758 if (validateDstSet) {
2759 // dstSet must be a valid VkDescriptorSet handle
2760 skip |= validate_required_handle(vkCallingFunction,
2761 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2762 pDescriptorWrites[i].dstSet);
2763 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002764
2765 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2766 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2767 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2768 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2769 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2770 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2771 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002772 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2773 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002774 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002775 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2776 "%s(): if pDescriptorWrites[%d].descriptorType is "
2777 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2778 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2779 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2780 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002781 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2782 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002783 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2784 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002785 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2786 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002787 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002788 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2789 ParameterName::IndexVector{i, descriptor_index}),
2790 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002791 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002792 }
2793 }
2794 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2795 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2796 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2797 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2798 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2799 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2800 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002801 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002802 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002803 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2804 "%s(): if pDescriptorWrites[%d].descriptorType is "
2805 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2806 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2807 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2808 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002809 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002810 const auto *robustness2_features =
2811 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2812 if (robustness2_features && robustness2_features->nullDescriptor) {
2813 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2814 ++descriptorIndex) {
2815 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2816 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2817 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2818 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2819 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2820 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2821 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2822 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2823 }
2824 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002825 }
2826 }
2827 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2828 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002829 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002830 }
2831
2832 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2833 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002834 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002835 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2836 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2837 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002838 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002839 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2840 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2841 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2842 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002843 }
2844 }
2845 }
2846 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2847 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002848 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002849 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2850 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2851 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002852 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002853 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2854 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2855 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2856 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 }
2858 }
2859 }
2860 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002861 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2862 // or VkWriteDescriptorSetInlineUniformBlockEX
2863 if (pDescriptorWrites[i].pNext) {
2864 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2865 const auto *pNext_struct =
2866 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2867 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2868 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2869 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2870 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2871 "accelerationStructureCount %d member equals descriptorCount %d.",
2872 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2873 pDescriptorWrites[i].descriptorCount);
2874 }
2875 // further checks only if we have right structtype
2876 if (pNext_struct) {
2877 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2878 skip |= LogError(
2879 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2880 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2881 ".",
2882 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2883 }
2884 if (pNext_struct->accelerationStructureCount == 0) {
2885 skip |= LogError(
2886 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2887 "%s(): accelerationStructureCount must be greater than 0 .");
2888 }
2889 }
2890 }
2891 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 }
2893 }
2894 return skip;
2895}
2896
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002897bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2898 const VkWriteDescriptorSet *pDescriptorWrites,
2899 uint32_t descriptorCopyCount,
2900 const VkCopyDescriptorSet *pDescriptorCopies) const {
2901 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2902}
2903
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002904bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002905 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002906 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002907 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2908}
2909
2910bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002911 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002912 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002913 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2914}
2915
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002916bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2917 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002918 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002920
2921 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2922 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2923 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002924 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2925 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002926 return skip;
2927}
2928
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002929bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002930 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002931 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002932
2933 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2934 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002935 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2936
Petr Krause7bb9e82019-08-11 21:34:43 +02002937 // Implicit VUs
2938 // validate only sType here; pointer has to be validated in core_validation
2939 const bool kNotRequired = false;
2940 const char *kNoVUID = nullptr;
2941 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2942 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2943 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002944
Petr Krause7bb9e82019-08-11 21:34:43 +02002945 if (pInfo) {
2946 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2947 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2948 skip |= validate_struct_pnext(
2949 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2950 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002951 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2952 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953
Petr Krause7bb9e82019-08-11 21:34:43 +02002954 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002955
Petr Krause7bb9e82019-08-11 21:34:43 +02002956 // Explicit VUs
2957 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002958 skip |= LogError(
2959 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002960 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2961 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002963
2964 if (physical_device_features.inheritedQueries) {
2965 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002966 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002967 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002968 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002969 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002970 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002971 }
2972
2973 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02002974 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002975 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002976 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02002977 } else { // !pipelineStatisticsQuery
2978 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
2979 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980 }
Petr Kraus139757b2019-08-15 17:19:33 +02002981
2982 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
2983 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002984 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02002985 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
2986 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002987 skip |= LogError(
2988 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02002989 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
2990 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
2991 }
2992 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993 }
2994
2995 return skip;
2996}
2997
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002998bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002999 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003001
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003002 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003003 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003004 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3005 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3006 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003007 }
3008 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003009 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3010 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3011 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003012 }
3013 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003014 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003015 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003016 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3017 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3018 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3019 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020 }
3021 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003022
3023 if (pViewports) {
3024 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3025 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003026 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003027 skip |= manual_PreCallValidateViewport(
3028 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003029 }
3030 }
3031
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003032 return skip;
3033}
3034
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003035bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003036 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003038
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003039 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003040 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003041 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3042 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3043 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003044 }
3045 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003046 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3047 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3048 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003049 }
3050 } else { // multiViewport enabled
3051 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003052 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003053 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3054 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3055 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3056 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003057 }
3058 }
3059
Petr Kraus6260f0a2018-02-27 21:15:55 +01003060 if (pScissors) {
3061 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3062 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003063
Petr Kraus6260f0a2018-02-27 21:15:55 +01003064 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003065 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3066 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3067 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003068 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003069
Petr Kraus6260f0a2018-02-27 21:15:55 +01003070 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003071 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3072 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3073 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003074 }
3075
3076 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3077 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003078 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3079 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3080 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3081 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003082 }
3083
3084 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3085 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003086 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3087 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3088 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3089 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003090 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003091 }
3092 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003093
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003094 return skip;
3095}
3096
Jeff Bolz5c801d12019-10-09 10:38:45 -05003097bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003098 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003099
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003100 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003101 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3102 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003103 }
3104
3105 return skip;
3106}
3107
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003108bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003109 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003110 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003111 if (vertexCount == 0) {
3112 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3113 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003114 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003115 }
3116
3117 if (instanceCount == 0) {
3118 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3119 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 }
3122 return skip;
3123}
3124
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003125bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003126 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003127 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003128
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003129 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003130 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3131 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 }
3133 return skip;
3134}
3135
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003136bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003137 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003139 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003140 skip |=
3141 LogError(device, kVUID_PVError_DeviceFeature,
3142 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003143 }
3144 return skip;
3145}
3146
sfricke-samsungf692b972020-05-02 08:00:45 -07003147bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3148 VkDeviceSize countBufferOffset, bool khr) const {
3149 bool skip = false;
3150 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3151 if (offset & 3) {
3152 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3153 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3154 }
3155
3156 if (countBufferOffset & 3) {
3157 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3158 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3159 countBufferOffset);
3160 }
3161 return skip;
3162}
3163
3164bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3165 VkDeviceSize offset, VkBuffer countBuffer,
3166 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3167 uint32_t stride) const {
3168 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3169}
3170
3171bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3172 VkDeviceSize offset, VkBuffer countBuffer,
3173 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3174 uint32_t stride) const {
3175 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3176}
3177
3178bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3179 VkDeviceSize countBufferOffset, bool khr) const {
3180 bool skip = false;
3181 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3182 if (offset & 3) {
3183 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3184 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3185 }
3186
3187 if (countBufferOffset & 3) {
3188 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3189 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3190 countBufferOffset);
3191 }
3192 return skip;
3193}
3194
3195bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3196 VkDeviceSize offset, VkBuffer countBuffer,
3197 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3198 uint32_t stride) const {
3199 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3200}
3201
3202bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3203 VkDeviceSize offset, VkBuffer countBuffer,
3204 VkDeviceSize countBufferOffset,
3205 uint32_t maxDrawCount, uint32_t stride) const {
3206 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3207}
3208
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003209bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3210 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003211 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003212 bool skip = false;
3213 for (uint32_t rect = 0; rect < rectCount; rect++) {
3214 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003215 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3216 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003217 }
sfricke-samsung10867682020-04-25 02:20:39 -07003218 if (pRects[rect].rect.extent.width == 0) {
3219 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3220 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3221 }
3222 if (pRects[rect].rect.extent.height == 0) {
3223 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3224 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3225 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003226 }
3227 return skip;
3228}
3229
Andrew Fobel3abeb992020-01-20 16:33:22 -05003230bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3231 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3232 VkImageFormatProperties2 *pImageFormatProperties,
3233 const char *apiName) const {
3234 bool skip = false;
3235
3236 if (pImageFormatInfo != nullptr) {
3237 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3238 if (image_stencil_struct != nullptr) {
3239 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3240 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3241 // No flags other than the legal attachment bits may be set
3242 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3243 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003244 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3245 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3246 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3247 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3248 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003249 }
3250 }
3251 }
3252 }
3253
3254 return skip;
3255}
3256
3257bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3258 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3259 VkImageFormatProperties2 *pImageFormatProperties) const {
3260 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3261 "vkGetPhysicalDeviceImageFormatProperties2");
3262}
3263
3264bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3265 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3266 VkImageFormatProperties2 *pImageFormatProperties) const {
3267 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3268 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3269}
3270
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003271bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3272 VkImageLayout srcImageLayout, VkImage dstImage,
3273 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003274 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003276
Dave Houltonf5217612018-02-02 16:18:52 -07003277 VkImageAspectFlags legal_aspect_flags =
3278 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 -07003279 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003280 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3281 }
3282
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003283 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003284 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003285 skip |= LogError(
3286 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003287 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003288 }
Dave Houltonf5217612018-02-02 16:18:52 -07003289 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003290 skip |= LogError(
3291 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003292 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293 }
3294 }
3295 return skip;
3296}
3297
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003298bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3299 VkImageLayout srcImageLayout, VkImage dstImage,
3300 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003301 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003302 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003303
Dave Houltonf5217612018-02-02 16:18:52 -07003304 VkImageAspectFlags legal_aspect_flags =
3305 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 -07003306 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003307 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3308 }
3309
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003310 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003311 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003312 skip |= LogError(
3313 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3315 }
Dave Houltonf5217612018-02-02 16:18:52 -07003316 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(
3318 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003319 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3320 }
3321 }
3322 return skip;
3323}
3324
sfricke-samsung3999ef62020-02-09 17:05:59 -08003325bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3326 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3327 bool skip = false;
3328
3329 if (pRegions != nullptr) {
3330 for (uint32_t i = 0; i < regionCount; i++) {
3331 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003332 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3333 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003334 }
3335 }
3336 }
3337 return skip;
3338}
3339
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003340bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3341 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003342 uint32_t regionCount,
3343 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003344 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345
Dave Houltonf5217612018-02-02 16:18:52 -07003346 VkImageAspectFlags legal_aspect_flags =
3347 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 -07003348 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003349 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3350 }
3351
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003352 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003353 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003354 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3355 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3356 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003357 }
3358 }
3359 return skip;
3360}
3361
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003362bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3363 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003364 uint32_t regionCount,
3365 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003366 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003367
Dave Houltonf5217612018-02-02 16:18:52 -07003368 VkImageAspectFlags legal_aspect_flags =
3369 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 -07003370 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003371 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3372 }
3373
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003374 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003375 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003376 skip |= LogError(
3377 device, kVUID_PVError_UnrecognizedValue,
3378 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3379 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003380 }
3381 }
3382 return skip;
3383}
3384
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003385bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003386 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3387 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003388 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003389
3390 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003391 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3392 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3393 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394 }
3395
3396 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003397 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3398 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3399 "), must be greater than zero and less than or equal to 65536.",
3400 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003402 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3403 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3404 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003405 }
3406 return skip;
3407}
3408
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003409bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003410 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412
3413 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003414 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3415 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3416 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003417 }
3418
3419 if (size != VK_WHOLE_SIZE) {
3420 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003421 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003422 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3423 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003424 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003425 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3426 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003427 }
3428 }
3429 return skip;
3430}
3431
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003432bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003433 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003434 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003435 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003436
3437 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3439 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3440 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3441 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003442 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3443 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3444 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003445 }
3446
3447 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3448 // queueFamilyIndexCount uint32_t values
3449 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003450 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3451 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3452 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3453 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 }
3455 }
3456
Dave Houlton413a6782018-05-22 13:01:54 -06003457 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003458 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003459 }
3460
3461 return skip;
3462}
3463
Jeff Bolz5c801d12019-10-09 10:38:45 -05003464bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003465 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003466
3467 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003468 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3469 if (present_regions) {
3470 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003471 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003472 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3473 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003474 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3475 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3476 "extension swapchainCount is %i. These values must be equal.",
3477 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003478 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003479 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003480 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3481 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003482 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3483 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3484 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003485 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003486 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003487 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003488 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003489 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003490 }
3491 }
3492
3493 return skip;
3494}
3495
3496#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003497bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3498 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3499 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003500 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003501 bool skip = false;
3502
3503 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003504 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3505 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003506 }
3507
3508 return skip;
3509}
3510#endif // VK_USE_PLATFORM_WIN32_KHR
3511
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003512bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003513 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003514 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003515 bool skip = false;
3516
3517 if (pCreateInfo) {
3518 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003519 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3520 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003521 }
3522
3523 if (pCreateInfo->pPoolSizes) {
3524 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3525 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003526 skip |= LogError(
3527 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003528 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003529 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003530 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3531 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003532 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3533 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3534 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3535 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3536 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003537 }
Petr Krausc8655be2017-09-27 18:56:51 +02003538 }
3539 }
3540 }
3541
3542 return skip;
3543}
3544
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003545bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003546 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003547 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003548
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003549 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003550 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003551 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3552 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3553 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003554 }
3555
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003556 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003557 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003558 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3559 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3560 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003561 }
3562
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003563 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003564 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003565 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3566 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3567 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003568 }
3569
3570 return skip;
3571}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003572
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003573bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003574 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003575 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003576
3577 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003578 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3579 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003580 }
3581 return skip;
3582}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003583
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003584bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3585 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003586 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003587 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003588
3589 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003590 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003591 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003592 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3593 "vkCmdDispatch(): baseGroupX (%" PRIu32
3594 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3595 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003596 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003597 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3598 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3599 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3600 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003601 }
3602
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003603 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003604 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003605 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3606 "vkCmdDispatch(): baseGroupY (%" PRIu32
3607 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3608 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003609 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003610 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3611 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3612 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3613 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003614 }
3615
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003616 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003617 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3619 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3620 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3621 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003622 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003623 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3624 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3625 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3626 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003627 }
3628
3629 return skip;
3630}
3631
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003632bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3633 VkPipelineBindPoint pipelineBindPoint,
3634 VkPipelineLayout layout, uint32_t set,
3635 uint32_t descriptorWriteCount,
3636 const VkWriteDescriptorSet *pDescriptorWrites) const {
3637 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3638}
3639
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003640bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3641 uint32_t firstExclusiveScissor,
3642 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003643 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003644 bool skip = false;
3645
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003646 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003647 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003648 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003649 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3650 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3651 ") is not 0.",
3652 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003653 }
3654 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003655 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003656 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3657 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3658 ") is not 1.",
3659 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003660 }
3661 } else { // multiViewport enabled
3662 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003663 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003664 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3665 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3666 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3667 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003668 }
3669 }
3670
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003671 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3673 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3674 ") must be less than maxViewports (=%" PRIu32 ").",
3675 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003676 }
3677
3678 if (pExclusiveScissors) {
3679 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3680 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3681
3682 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003683 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3684 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3685 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003686 }
3687
3688 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003689 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3690 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3691 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003692 }
3693
3694 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3695 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003696 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3697 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3698 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3699 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003700 }
3701
3702 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3703 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003704 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3705 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3706 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3707 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003708 }
3709 }
3710 }
3711
3712 return skip;
3713}
3714
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003715bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3716 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003717 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003718 bool skip = false;
3719 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003720 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3721 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3722 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003723 } else {
3724 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3725 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003726 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3727 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3728 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3729 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003730 }
3731 }
3732
3733 return skip;
3734}
3735
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003736bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3737 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003738 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003739 bool skip = false;
3740
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003741 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003742 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003743 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3745 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3746 ") is not 0.",
3747 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003748 }
3749 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003750 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003751 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3752 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3753 ") is not 1.",
3754 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003755 }
3756 }
3757
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003758 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003759 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3760 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3761 ") must be less than maxViewports (=%" PRIu32 ").",
3762 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003763 }
3764
3765 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003766 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003767 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3768 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3769 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3770 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003771 }
3772
3773 return skip;
3774}
3775
Jeff Bolz5c801d12019-10-09 10:38:45 -05003776bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3777 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3778 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003779 bool skip = false;
3780
Dave Houlton142c4cb2018-10-17 15:04:41 -06003781 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003782 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3783 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3784 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003785 }
3786
3787 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003788 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003789 }
3790
3791 return skip;
3792}
3793
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003794bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003795 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003796 bool skip = false;
3797
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003798 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003799 skip |= LogError(
3800 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003801 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3802 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003803 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003804 }
3805
3806 return skip;
3807}
3808
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003809bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3810 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003811 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003812 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003813 static const int condition_multiples = 0b0011;
3814 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003815 skip |= LogError(
3816 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003817 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003818 }
Lockee1c22882019-06-10 16:02:54 -06003819 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003820 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3821 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3822 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3823 stride);
Lockee1c22882019-06-10 16:02:54 -06003824 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003825 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003826 skip |= LogError(
3827 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3828 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003829 }
3830
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003831 return skip;
3832}
3833
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003834bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3835 VkDeviceSize offset, VkBuffer countBuffer,
3836 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003837 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003838 bool skip = false;
3839
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003840 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003841 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3842 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3843 "), is not a multiple of 4.",
3844 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003845 }
3846
3847 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003848 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3849 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3850 "), is not a multiple of 4.",
3851 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003852 }
3853
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003854 return skip;
3855}
3856
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003857bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003858 const VkAllocationCallbacks *pAllocator,
3859 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003860 bool skip = false;
3861
3862 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3863 if (pCreateInfo != nullptr) {
3864 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3865 // VkQueryPipelineStatisticFlagBits values
3866 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3867 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003868 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3869 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3870 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3871 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003872 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003873 if (pCreateInfo->queryCount == 0) {
3874 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3875 "vkCreateQueryPool(): queryCount must be greater than zero.");
3876 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003877 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003878 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003879}
3880
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003881bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3882 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003883 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003884 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3885 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003886}
3887
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003888void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003889 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3890 VkResult result) {
3891 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003892 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003893}
3894
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003895void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003896 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3897 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003898 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003899 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003900 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003901}
3902
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003903void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3904 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003905 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003906 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003907 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003908}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003909
3910bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003911 const VkAllocationCallbacks *pAllocator,
3912 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003913 bool skip = false;
3914
3915 if (pAllocateInfo) {
3916 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3917 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003918 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3919 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003920 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003921
3922 VkMemoryAllocateFlags flags = 0;
3923 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3924 if (flags_info) {
3925 flags = flags_info->flags;
3926 }
3927
3928 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3929 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3930 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003931 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3932 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3933 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003934 }
3935
3936#ifdef VK_USE_PLATFORM_WIN32_KHR
3937 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3938#endif
3939 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3940 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3941#ifdef VK_USE_PLATFORM_ANDROID_KHR
3942 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3943#endif
3944
3945 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003946 skip |= LogError(
3947 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003948 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3949 }
3950 if (
3951#ifdef VK_USE_PLATFORM_WIN32_KHR
3952 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3953#endif
3954 (import_memory_fd && import_memory_fd->handleType) ||
3955#ifdef VK_USE_PLATFORM_ANDROID_KHR
3956 (import_memory_ahb && import_memory_ahb->buffer) ||
3957#endif
3958 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003959 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3960 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003961 }
3962 }
3963
3964 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003965 VkBool32 capture_replay = false;
3966 VkBool32 buffer_device_address = false;
3967 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3968 if (vulkan_12_features) {
3969 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3970 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3971 } else {
3972 const auto *bda_features =
3973 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
3974 if (bda_features) {
3975 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
3976 buffer_device_address = bda_features->bufferDeviceAddress;
3977 }
3978 }
3979 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003980 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
3981 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
3982 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003983 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003984 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003985 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
3986 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003987 }
3988 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003989 }
3990 return skip;
3991}
Ricardo Garciaa4935972019-02-21 17:43:18 +01003992
Jason Macnak192fa0e2019-07-26 15:07:16 -07003993bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003994 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07003995 bool skip = false;
3996
3997 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
3998 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
3999 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004000 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004001 } else {
4002 uint32_t vertex_component_size = 0;
4003 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4004 vertex_component_size = 4;
4005 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4006 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4007 vertex_component_size = 2;
4008 }
4009 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004010 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004011 }
4012 }
4013
4014 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4015 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004016 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004017 } else {
4018 uint32_t index_element_size = 0;
4019 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4020 index_element_size = 4;
4021 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4022 index_element_size = 2;
4023 }
4024 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004025 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004026 }
4027 }
4028 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4029 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004030 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004031 }
4032 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004033 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004034 }
4035 }
4036
4037 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004038 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004039 }
4040
4041 return skip;
4042}
4043
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004044bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4045 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004046 bool skip = false;
4047
4048 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004049 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004050 }
4051 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004052 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004053 }
4054
4055 return skip;
4056}
4057
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004058bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4059 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004060 bool skip = false;
4061 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004062 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004063 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004064 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004065 }
4066 return skip;
4067}
4068
4069bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004070 VkAccelerationStructureNV object_handle,
Jason Macnak192fa0e2019-07-26 15:07:16 -07004071 const char *func_name) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004072 bool skip = false;
4073 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004074 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4075 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4076 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004077 }
4078 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004079 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4080 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4081 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004082 }
4083 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4084 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004085 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4086 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4087 "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 -07004088 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004089 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004090 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
4091 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4092 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004093 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004094 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004095 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4096 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4097 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004098 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004099 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004100 uint64_t total_triangle_count = 0;
4101 for (uint32_t i = 0; i < info.geometryCount; i++) {
4102 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004103
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004104 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004105
Jason Macnak5c954952019-07-09 15:46:12 -07004106 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4107 continue;
4108 }
4109 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4110 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004111 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4113 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4114 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004115 }
4116 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004117 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4118 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4119 for (uint32_t i = 1; i < info.geometryCount; i++) {
4120 const VkGeometryNV &geometry = info.pGeometries[i];
4121 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004122 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004123 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4124 "info.pGeometries[0].geometryType.",
4125 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004126 }
4127 }
4128 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004129 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4130 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4131 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4132 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4133 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4134 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4135 }
4136 }
4137 skip |=
4138 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
4139 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07004140 return skip;
4141}
4142
Ricardo Garciaa4935972019-02-21 17:43:18 +01004143bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4144 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004145 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004146 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004147 if (pCreateInfo) {
4148 if ((pCreateInfo->compactedSize != 0) &&
4149 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004150 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4151 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4152 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4153 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004154 }
Jason Macnak5c954952019-07-09 15:46:12 -07004155
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004156 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
Jason Macnak192fa0e2019-07-26 15:07:16 -07004157 "vkCreateAccelerationStructureNV()");
Ricardo Garciaa4935972019-02-21 17:43:18 +01004158 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004159 return skip;
4160}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004161
Jeff Bolz5c801d12019-10-09 10:38:45 -05004162bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4163 const VkAccelerationStructureInfoNV *pInfo,
4164 VkBuffer instanceData, VkDeviceSize instanceOffset,
4165 VkBool32 update, VkAccelerationStructureNV dst,
4166 VkAccelerationStructureNV src, VkBuffer scratch,
4167 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004168 bool skip = false;
4169
4170 if (pInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004171 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()");
Jason Macnak5c954952019-07-09 15:46:12 -07004172 }
4173
4174 return skip;
4175}
4176
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004177bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4178 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4179 VkAccelerationStructureKHR *pAccelerationStructure) const {
4180 bool skip = false;
4181
4182 if (pCreateInfo) {
4183 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4184 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4185 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4186 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4187 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4188 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4189 i);
4190 }
4191 }
4192
4193 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4194 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4195 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4196 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4197 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4198 i);
4199 }
4200 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004201 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4202 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4203 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4204 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4205 skip |= LogError(
4206 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4207 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4208 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4209 }
4210 }
4211 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4212 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4213 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4214 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4215 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4216 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4217 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4218 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4219 }
4220 }
4221 }
4222
4223 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4224 pCreateInfo->maxGeometryCount != 1) {
4225 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4226 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4227 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004228 }
4229
4230 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4231 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4232 skip |= LogError(
4233 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4234 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4235 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4236 }
4237
4238 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4239 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4240 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4241 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4242 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4243 }
4244
4245 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4246 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4247 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4248 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4249 if (geometry_type != first_geometry_type) {
4250 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4251 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4252 "pGeometryInfos[0].geometryType.",
4253 i);
4254 }
4255 }
4256 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004257 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4258 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4259 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4260 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4261 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4262 "maxGeometryCount %d.",
4263 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4264 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004265 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004266 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4267 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4268 if (pCreateInfo->deviceAddress != 0) {
4269 skip |=
4270 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4271 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4272 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4273 }
4274 }
sourav parmar83c31b12020-05-06 12:30:54 -07004275 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4276 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4277 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4278 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004279 return skip;
4280}
4281
Jason Macnak5c954952019-07-09 15:46:12 -07004282bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4283 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004284 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004285 bool skip = false;
4286 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004287 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4288 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004289 }
4290 return skip;
4291}
4292
Peter Chen85366392019-05-14 15:20:11 -04004293bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4294 uint32_t createInfoCount,
4295 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4296 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004297 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004298 bool skip = false;
4299
4300 for (uint32_t i = 0; i < createInfoCount; i++) {
4301 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4302 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004303 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004304 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4305 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4306 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4307 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004308 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004309
4310 const auto *pipeline_cache_contol_features =
4311 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4312 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4313 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4314 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4315 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4316 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4317 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4318 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4319 }
4320 }
4321
sourav parmarf4a78252020-04-10 13:04:21 -07004322 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4323 skip |=
4324 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4325 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4326 }
4327 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4328 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4329 skip |=
4330 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4331 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4332 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4333 }
4334 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4335 if (pCreateInfos[i].basePipelineIndex != -1) {
4336 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4337 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4338 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4339 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4340 "and pCreateInfos->basePipelineIndex is not -1.");
4341 }
4342 }
4343 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4344 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4345 skip |=
4346 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4347 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4348 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4349 "commands pCreateInfos parameter.");
4350 }
4351 } else {
4352 if (pCreateInfos[i].basePipelineIndex != -1) {
4353 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4354 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4355 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4356 }
4357 }
4358 }
4359 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4360 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4361 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4362 }
4363 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4364 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4365 "vkCreateRayTracingPipelinesNV: flags must not include "
4366 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4367 }
4368 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4369 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4370 "vkCreateRayTracingPipelinesNV: flags must not include "
4371 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4372 }
4373 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4374 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4375 "vkCreateRayTracingPipelinesNV: flags must not include "
4376 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4377 }
4378 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4379 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4380 "vkCreateRayTracingPipelinesNV: flags must not include "
4381 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4382 }
4383 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4384 skip |= LogError(
4385 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4386 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4387 }
4388 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4389 skip |= LogError(
4390 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4391 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4392 }
Peter Chen85366392019-05-14 15:20:11 -04004393 }
4394
4395 return skip;
4396}
4397
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004398bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4399 uint32_t createInfoCount,
4400 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4401 const VkAllocationCallbacks *pAllocator,
4402 VkPipeline *pPipelines) const {
4403 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004404 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4405 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4406 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4407 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4408 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004409 for (uint32_t i = 0; i < createInfoCount; i++) {
4410 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4411 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4412 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4413 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4414 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4415 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4416 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4417 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004418 const auto *pipeline_cache_contol_features =
4419 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4420 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4421 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4422 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4423 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4424 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4425 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4426 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4427 }
4428 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004429 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4430 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4431 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4432 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4433 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4434 }
4435 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4436 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4437 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4438 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4439 }
4440 }
4441
sourav parmarf4a78252020-04-10 13:04:21 -07004442 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4443 skip |=
4444 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4445 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4446 }
4447 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4448 if (pCreateInfos[i].pLibraryInterface == NULL)
4449 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4450 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4451 }
4452 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4453 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4454 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4455 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4456 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4457 skip |= LogError(
4458 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4459 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4460 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4461 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4462 "must not be VK_SHADER_UNUSED_KHR");
4463 }
4464 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4465 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4466 skip |= LogError(
4467 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4468 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4469 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4470 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4471 "element must not be VK_SHADER_UNUSED_KHR");
4472 }
4473 }
4474 }
4475 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4476 if (pCreateInfos[i].basePipelineIndex != -1) {
4477 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4478 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4479 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4480 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4481 "and pCreateInfos->basePipelineIndex is not -1.");
4482 }
4483 }
4484 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4485 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4486 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4487 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4488 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4489 "commands pCreateInfos parameter %d.",
4490 pCreateInfos[i].basePipelineIndex, createInfoCount);
4491 }
4492 } else {
4493 if (pCreateInfos[i].basePipelineIndex != -1) {
4494 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4495 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4496 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4497 }
4498 }
4499 }
4500 if (pCreateInfos[i].libraries.libraryCount == 0) {
4501 if (pCreateInfos[i].stageCount == 0) {
4502 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4503 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4504 }
4505 if (pCreateInfos[i].groupCount == 0) {
4506 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4507 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4508 }
4509 } else {
4510 if (pCreateInfos[i].pLibraryInterface == NULL) {
4511 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4512 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4513 }
4514 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004515 }
4516
4517 return skip;
4518}
4519
Mike Schuchardt21638df2019-03-16 10:52:02 -07004520#ifdef VK_USE_PLATFORM_WIN32_KHR
4521bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4522 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004523 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004524 bool skip = false;
4525 if (!device_extensions.vk_khr_swapchain)
4526 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4527 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4528 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4529 if (!device_extensions.vk_khr_surface)
4530 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4531 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4532 skip |=
4533 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4534 if (!device_extensions.vk_ext_full_screen_exclusive)
4535 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4536 skip |= validate_struct_type(
4537 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4538 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4539 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4540 if (pSurfaceInfo != NULL) {
4541 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4542 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4543 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4544
4545 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4546 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4547 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4548 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004549 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4550 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004551
4552 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4553 }
4554 return skip;
4555}
4556#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004557
4558bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4559 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004560 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004561 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4562 bool skip = false;
4563 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4564 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4565 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4566 }
4567 return skip;
4568}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004569
4570bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004571 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004572 bool skip = false;
4573
4574 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004575 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4576 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004577 }
4578
4579 return skip;
4580}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004581
4582bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004583 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004584 bool skip = false;
4585
4586 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004587 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4588 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004589 }
4590
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004591 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004592 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004593 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4594 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004595 }
4596
4597 return skip;
4598}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004599
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004600bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4601 uint32_t bindingCount, const VkBuffer *pBuffers,
4602 const VkDeviceSize *pOffsets) const {
4603 bool skip = false;
4604 if (firstBinding > device_limits.maxVertexInputBindings) {
4605 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4606 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4607 device_limits.maxVertexInputBindings);
4608 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4609 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4610 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4611 "maxVertexInputBindings (%u)",
4612 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4613 }
4614
Jeff Bolz165818a2020-05-08 11:19:03 -05004615 for (uint32_t i = 0; i < bindingCount; ++i) {
4616 if (pBuffers[i] == VK_NULL_HANDLE) {
4617 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4618 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4619 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4620 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4621 } else {
4622 if (pOffsets[i] != 0) {
4623 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4624 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4625 }
4626 }
4627 }
4628 }
4629
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004630 return skip;
4631}
4632
Mark Lobodzinski84988402019-09-11 15:27:30 -06004633bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004634 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004635 bool skip = false;
4636 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004637 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4638 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004639 }
4640 return skip;
4641}
4642
4643bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004644 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004645 bool skip = false;
4646 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004647 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4648 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004649 }
4650 return skip;
4651}
Petr Kraus3d720392019-11-13 02:52:39 +01004652
4653bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4654 VkSemaphore semaphore, VkFence fence,
4655 uint32_t *pImageIndex) const {
4656 bool skip = false;
4657
4658 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004659 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4660 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004661 }
4662
4663 return skip;
4664}
4665
4666bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4667 uint32_t *pImageIndex) const {
4668 bool skip = false;
4669
4670 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004671 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4672 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004673 }
4674
4675 return skip;
4676}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004677
4678bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4679 uint32_t firstInstance, VkBuffer counterBuffer,
4680 VkDeviceSize counterBufferOffset,
4681 uint32_t counterOffset, uint32_t vertexStride) const {
4682 bool skip = false;
4683
4684 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004685 skip |= LogError(
4686 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004687 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4688 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4689 }
4690
4691 return skip;
4692}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004693
4694bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4695 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4696 const VkAllocationCallbacks *pAllocator,
4697 VkSamplerYcbcrConversion *pYcbcrConversion,
4698 const char *apiName) const {
4699 bool skip = false;
4700
4701 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004702 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004703 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004704 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4705 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004706 }
4707 return skip;
4708}
4709
4710bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4711 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4712 const VkAllocationCallbacks *pAllocator,
4713 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4714 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4715 "vkCreateSamplerYcbcrConversion");
4716}
4717
4718bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4719 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4720 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4721 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4722 "vkCreateSamplerYcbcrConversionKHR");
4723}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004724
4725bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4726 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4727 bool skip = false;
4728 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4729 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4730
4731 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004732 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4733 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4734 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4735 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4736 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004737 }
4738 return skip;
4739}
sourav parmara96ab1a2020-04-25 16:28:23 -07004740
4741bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4742 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4743 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004744 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4745 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4746 skip |=
4747 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4748 "vkCopyAccelerationStructureToMemoryKHR: the "
4749 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4750 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004751 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4752 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4753 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4754 }
4755 return skip;
4756}
4757
4758bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4759 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4760 bool skip = false;
4761 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4762 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4763 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4764 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4765 }
sourav parmar83c31b12020-05-06 12:30:54 -07004766 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4767 if (pNext_struct) {
4768 skip |= LogError(
4769 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4770 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4771 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4772 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004773 return skip;
4774}
4775
4776bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4777 const char *api_name) const {
4778 bool skip = false;
4779 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4780 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4781 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4782 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4783 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4784 api_name);
4785 }
4786 return skip;
4787}
4788
4789bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4790 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4791 bool skip = false;
4792 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004793 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4794 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4795 skip |= LogError(
4796 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4797 "vkCopyAccelerationStructureKHR(): the "
4798 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4799 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004800 return skip;
4801}
4802
4803bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4804 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4805 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004806 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4807 if (pNext_struct) {
4808 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4809 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4810 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4811 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004812 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4813 return skip;
4814}
4815
4816bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004817 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004818 bool skip = false;
4819 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004820 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004821 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
4822 : "VUID-vkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07004823 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4824 }
4825 return skip;
4826}
4827
4828bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4829 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4830 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004831 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
4832 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4833 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4834 skip |=
4835 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
4836 "vkCopyMemoryToAccelerationStructureKHR() :the "
4837 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4838 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004839 return skip;
4840}
4841bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4842 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4843 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004844 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
4845 return skip;
4846}
4847bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
4848 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4849 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4850 bool skip = false;
4851 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4852 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4853 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4854 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
4855 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4856 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4857 }
4858 return skip;
4859}
4860bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
4861 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
4862 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
4863 bool skip = false;
4864 if (dataSize < accelerationStructureCount * stride) {
4865 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
4866 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
4867 "accelerationStructureCount (%d) *stride(%zu).",
4868 dataSize, accelerationStructureCount, stride);
4869 }
4870 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4871 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4872 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
4873 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
4874 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4875 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4876 }
4877 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
4878 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4879 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
4880 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4881 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
4882 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4883 stride);
4884 }
4885 }
4886 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
4887 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
4888 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
4889 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
4890 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
4891 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
4892 stride);
4893 }
4894 }
4895 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4896 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4897 skip |=
4898 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
4899 "vkWriteAccelerationStructuresPropertiesKHR: the "
4900 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
4901 "feature must be enabled ");
4902 }
4903 return skip;
4904}
4905bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
4906 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
4907 bool skip = false;
4908 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4909 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
4910 skip |= LogError(device,
4911 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
4912 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
4913 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
4914 "must be enabled to call this function.");
4915 }
4916 return skip;
4917}
4918
4919bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
4920 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4921 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4922 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4923 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4924 uint32_t width, uint32_t height, uint32_t depth) const {
4925 bool skip = false;
4926 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4927 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
4928 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
4929 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4930 }
4931 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4932 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
4933 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
4934 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4935 }
4936 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4937 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
4938 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
4939 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4940 }
4941 // hitShader
4942 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4943 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
4944 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
4945 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4946 }
4947 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4948 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
4949 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
4950 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4951 }
4952 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4953 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
4954 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
4955 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4956 }
4957
4958 // missShader
4959 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4960 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
4961 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
4962 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4963 }
4964 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
4965 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
4966 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
4967 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
4968 }
4969 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
4970 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
4971 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
4972 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
4973 }
4974
4975 // raygenShader
4976 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4977 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
4978 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
4979 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
4980 }
4981 return skip;
4982}
4983
4984bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
4985 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
4986 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
4987 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
4988 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
4989 VkBuffer buffer, VkDeviceSize offset) const {
4990 bool skip = false;
4991 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4992 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
4993 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
4994 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
4995 "feature must be enabled.");
4996 }
4997 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
4998 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
4999 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5000 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5001 }
5002 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5003 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5004 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5005 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5006 }
5007 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5008 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5009 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5010 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5011 }
5012 // hitShader
5013 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5014 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5015 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5016 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5017 }
5018 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5019 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5020 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5021 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5022 }
5023 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5024 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5025 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5026 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5027 }
5028
5029 // missShader
5030 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5031 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5032 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5033 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5034 }
5035 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5036 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5037 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5038 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5039 }
5040 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5041 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5042 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5043 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5044 }
5045
5046 // raygenShader
5047 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5048 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5049 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5050 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5051 }
5052 return skip;
5053}
5054bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5055 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5056 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5057 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5058 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5059 uint32_t width, uint32_t height, uint32_t depth) const {
5060 bool skip = false;
5061 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5062 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5063 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5064 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5065 }
5066 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5067 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5068 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5069 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5070 }
5071 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5072 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5073 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5074 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5075 }
5076
5077 // hitShader
5078 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5079 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5080 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5081 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5082 }
5083 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5084 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5085 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5086 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5087 }
5088 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5089 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5090 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5091 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5092 }
5093
5094 // missShader
5095 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5096 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5097 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5098 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5099 }
5100 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5101 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5102 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5103 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5104 }
5105 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5106 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5107 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5108 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5109 }
5110
5111 // raygenShader
5112 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5113 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5114 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
5115 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment .");
5116 }
5117 return skip;
5118}
5119
5120bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5121 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5122 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5123 bool skip = false;
5124 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5125 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5126 skip |= LogError(
5127 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5128 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5129 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5130 }
5131 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5132 if (pNext_struct) {
5133 skip |=
5134 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5135 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5136 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5137 }
5138 return false;
5139}
5140
5141bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5142 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5143 bool skip = false;
5144 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5145 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5146 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5147 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5148 }
5149 return skip;
5150}
5151
5152bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5153 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5154 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5155 bool skip = false;
5156 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5157 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5158 skip |= LogError(
5159 device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5160 "vkBuildAccelerationStructureKHR: The "
5161 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5162 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005163 return skip;
5164}