blob: 9172bc86d021351968fc1a991a7bf5c9a5ac819a [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600489 return skip;
490}
491
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500492bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700493 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700494 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
495 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
496 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600497 }
498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700499 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600500}
501
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700502bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500503 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100504 bool skip = false;
505
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600506 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700507 skip |=
508 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600509
510 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
511 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
512 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
513 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700514 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
515 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
516 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600517 }
518
519 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
520 // queueFamilyIndexCount uint32_t values
521 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700522 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
523 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
524 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
525 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600526 }
527 }
528
529 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
530 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
531 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
532 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700533 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
534 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
535 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600536 }
537 }
538
539 return skip;
540}
541
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700542bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500543 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600544 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600545
546 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600547 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
548 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
549 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
550 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700551 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
552 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
553 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600554 }
555
556 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
557 // queueFamilyIndexCount uint32_t values
558 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700559 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
560 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
561 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
562 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600563 }
564 }
565
Dave Houlton413a6782018-05-22 13:01:54 -0600566 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700567 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600568 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700569 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600570 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700571 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600572
Dave Houlton413a6782018-05-22 13:01:54 -0600573 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700574 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600575 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700576 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577
Dave Houlton130c0212018-01-29 13:39:56 -0700578 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700579 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
580 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700581 skip |= LogError(
582 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600583 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
584 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700585 }
586
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600587 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100588 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
589 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700590 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
591 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
592 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600593 }
594
595 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100596 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
597 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700598 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
599 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
600 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
601 ") are not equal.",
602 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100603 }
604
605 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700606 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
607 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
608 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
609 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100610 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600611 }
612
613 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700614 skip |= LogError(
615 device, "VUID-VkImageCreateInfo-imageType-00957",
616 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600617 }
618 }
619
Dave Houlton130c0212018-01-29 13:39:56 -0700620 // 3D image may have only 1 layer
621 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700622 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
623 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700624 }
625
626 // If multi-sample, validate type, usage, tiling and mip levels.
627 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
628 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600629 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700630 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
631 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700632 }
633
634 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
635 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
636 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
637 // At least one of the legal attachment bits must be set
638 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700639 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
640 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700641 }
642 // No flags other than the legal attachment bits may be set
643 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
644 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
646 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700647 }
648 }
649
Jeff Bolzef40fec2018-09-01 22:04:34 -0500650 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600651 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500652 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600653 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
654 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500655 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600656 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700657 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
658 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
659 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600660 }
661
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600662 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700663 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
664 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
665 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600666 }
667
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700668 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700669 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
670 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
671 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100672 }
673
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
675 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
676 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
677 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700678 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
679 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
680 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600681 }
682
683 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
684 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
685 // Linear tiling is unsupported
686 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700687 skip |= LogError(device, kVUID_PVError_InvalidUsage,
688 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
689 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600690 }
691
692 // Sparse 1D image isn't valid
693 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700694 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
695 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600696 }
697
698 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700699 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700700 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
701 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
702 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600703 }
704
705 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700706 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700707 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
708 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
709 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600710 }
711
712 // Multi-sample 2D image when device doesn't support it
713 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700714 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600715 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700716 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
717 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
718 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700719 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600720 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700721 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
722 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
723 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700724 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600725 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
727 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
728 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700729 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600730 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700731 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
732 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
733 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600734 }
735 }
736 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500737
Jeff Bolz9af91c52018-09-01 21:53:57 -0500738 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
739 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700740 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
741 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
742 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500743 }
744 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700745 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
746 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
747 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500748 }
749 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700750 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
751 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
752 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500753 }
754 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500755
756 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600757 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700758 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
759 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
760 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500761 }
762
Dave Houlton142c4cb2018-10-17 15:04:41 -0600763 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
765 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
766 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
767 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500768 }
769
Dave Houlton142c4cb2018-10-17 15:04:41 -0600770 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700771 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
772 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
773 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
774 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500775 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600776 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700777 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
778 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
779 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
780 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500781 }
782 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500783
sfricke-samsung8f658d42020-05-03 20:12:24 -0700784 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
785 (FormatHasDepth(pCreateInfo->format) == false)) {
786 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
787 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
788 "format must be a depth or depth/stencil format.");
789 }
790
Andrew Fobel3abeb992020-01-20 16:33:22 -0500791 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
792 if (image_stencil_struct != nullptr) {
793 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
794 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
795 // No flags other than the legal attachment bits may be set
796 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
797 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700798 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
799 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
800 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
801 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500802 }
803 }
804
805 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
806 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
807 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
808 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700809 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
810 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
811 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
812 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500813 }
814
815 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
816 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700817 LogError(device, "VUID-VkImageCreateInfo-format-02537",
818 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
819 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
820 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500821 }
822 }
823
824 if (!physical_device_features.shaderStorageImageMultisample &&
825 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
826 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
827 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700828 LogError(device, "VUID-VkImageCreateInfo-format-02538",
829 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
830 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
831 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500832 }
833
834 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
835 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700836 skip |= LogError(
837 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500838 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
839 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
840 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
841 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
842 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700843 skip |= LogError(
844 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500845 "vkCreateImage(): Depth-stencil image in which usage does not include "
846 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
847 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
848 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
849 }
850
851 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
852 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700853 skip |= LogError(
854 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500855 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
856 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
857 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
858 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
859 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700860 skip |= LogError(
861 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500862 "vkCreateImage(): Depth-stencil image in which usage does not include "
863 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
864 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
865 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
866 }
867 }
868 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700869
870 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
871 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
872 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
873 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
874 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
875 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700876
877 if (device_extensions.vk_ext_image_drm_format_modifier) {
878 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
879 const auto drm_format_mod_explict =
880 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
881 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
882 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
883 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
884 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
885 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
886 "either VkImageDrmFormatModifierListCreateInfoEXT or "
887 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
888 }
889 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
890 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
891 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
892 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
893 "in the pNext chain");
894 }
895 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200896
897 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
898 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
899 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
900 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
901 "imageType must be VK_IMAGE_TYPE_2D.");
902 }
903 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
904 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
905 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
906 "samples must be VK_SAMPLE_COUNT_1_BIT.");
907 }
908 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
909 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
910 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
911 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
912 }
913 }
914 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
915 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
916 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
917 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
918 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
919 }
920 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
921 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
922 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
923 "imageType must be VK_IMAGE_TYPE_2D.");
924 }
925 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
926 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
927 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
928 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
929 }
930 if (pCreateInfo->mipLevels != 1) {
931 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
932 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
933 pCreateInfo->mipLevels);
934 }
935 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600936 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500937
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600938 return skip;
939}
940
Jeff Bolz99e3f632020-03-24 22:59:22 -0500941bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
942 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
943 bool skip = false;
944
945 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700946 // Validate feature set if using CUBE_ARRAY
947 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
948 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
949 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
950 "enabling the imageCubeArray feature.");
951 }
952
Jeff Bolz99e3f632020-03-24 22:59:22 -0500953 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
954 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
955 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700956 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500957 pCreateInfo->subresourceRange.layerCount);
958 }
959 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700960 skip |= LogError(
961 device, "VUID-VkImageViewCreateInfo-viewType-02961",
962 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
963 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500964 }
965 }
966 }
967 return skip;
968}
969
Jeff Bolz6d3beaa2019-02-09 21:00:05 -0600970bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700971 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +0100972 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100973
974 // Note: for numerical correctness
975 // - float comparisons should expect NaN (comparison always false).
976 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
977
978 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -0700979 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +0100980 if (v1_f <= 0.0f) return true;
981
982 float intpart;
983 const float fract = modff(v1_f, &intpart);
984
985 assert(std::numeric_limits<float>::radix == 2);
986 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
987 if (intpart >= u32_max_plus1) return false;
988
989 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
990 if (v1_u32 < v2_u32)
991 return true;
992 else if (v1_u32 == v2_u32 && fract == 0.0f)
993 return true;
994 else
995 return false;
996 };
997
998 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
999 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1000 return (v1_f <= v2_f);
1001 };
1002
1003 // width
1004 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001005 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001006
1007 if (!(viewport.width > 0.0f)) {
1008 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001009 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1010 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001011 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1012 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001013 skip |= LogError(object, "VUID-VkViewport-width-01771",
1014 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1015 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001016 } 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 -07001017 skip |= LogWarning(object, kVUID_PVError_NONE,
1018 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1019 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1020 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001021 }
1022
1023 // height
1024 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001025 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001026 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001027
1028 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1029 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001030 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1031 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001032 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1033 height_healthy = false;
1034
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001035 skip |= LogError(object, "VUID-VkViewport-height-01773",
1036 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1037 ").",
1038 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001039 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1040 height_healthy = false;
1041
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001042 skip |= LogWarning(
1043 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001044 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001045 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001046 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001047 }
1048
1049 // x
1050 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001051 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001052 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001053 skip |= LogError(object, "VUID-VkViewport-x-01774",
1054 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1055 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001056 }
1057
1058 // x + width
1059 if (x_healthy && width_healthy) {
1060 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001061 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001062 skip |= LogError(
1063 object, "VUID-VkViewport-x-01232",
1064 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1065 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1066 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001067 }
1068 }
1069
1070 // y
1071 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001072 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001073 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001074 skip |= LogError(object, "VUID-VkViewport-y-01775",
1075 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1076 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001077 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001078 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001079 skip |= LogError(object, "VUID-VkViewport-y-01776",
1080 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1081 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001082 }
1083
1084 // y + height
1085 if (y_healthy && height_healthy) {
1086 const float boundary = viewport.y + viewport.height;
1087
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001088 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001089 skip |= LogError(object, "VUID-VkViewport-y-01233",
1090 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1091 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1092 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001093 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001094 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001095 LogError(object, "VUID-VkViewport-y-01777",
1096 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1097 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1098 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001099 }
1100 }
1101
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001102 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001103 // minDepth
1104 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001105 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001106
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001107 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1108 "[0.0, 1.0] range.",
1109 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001110 }
1111
1112 // maxDepth
1113 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001114 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001115
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001116 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1117 "[0.0, 1.0] range.",
1118 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001119 }
1120 }
1121
1122 return skip;
1123}
1124
Dave Houlton142c4cb2018-10-17 15:04:41 -06001125struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001126 VkShadingRatePaletteEntryNV shadingRate;
1127 uint32_t width;
1128 uint32_t height;
1129};
1130
1131// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001132static SampleOrderInfo sampleOrderInfos[] = {
1133 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1134 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1135 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1136 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1137 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1138 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001139};
1140
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001141bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001142 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001143
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001144 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001145 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001146 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001147 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001148 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001149 break;
1150 }
1151 }
1152
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001153 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001154 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1155 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1156 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001157 return skip;
1158 }
1159
Dave Houlton142c4cb2018-10-17 15:04:41 -06001160 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001161 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001162 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1163 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1164 ") must "
1165 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1166 "is set in framebufferNoAttachmentsSampleCounts.",
1167 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001168 }
1169
Jeff Bolz9af91c52018-09-01 21:53:57 -05001170 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001171 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1172 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1173 ") must "
1174 "be equal to the product of sampleCount (=%" PRIu32
1175 "), the fragment width for shadingRate "
1176 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1177 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001178 }
1179
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001180 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001181 skip |= LogError(
1182 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001183 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1184 ") must "
1185 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001186 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001187 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001188
1189 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001190 // the first width*height*sampleCount bits to all be set. Note: There is no
1191 // guarantee that 64 bits is enough, but practically it's unlikely for an
1192 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001193 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001194 uint64_t sampleLocationsMask = 0;
1195 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1196 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1197 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001198 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1199 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001200 }
1201 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001202 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1203 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001204 }
1205 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001206 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1207 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001208 }
1209 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1210 sampleLocationsMask |= 1ULL << idx;
1211 }
1212
1213 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1214 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001215 skip |= LogError(
1216 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001217 "The array pSampleLocations must contain exactly one entry for "
1218 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001219 }
1220
1221 return skip;
1222}
1223
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001224bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1225 uint32_t createInfoCount,
1226 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1227 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001228 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001229 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001230
1231 if (pCreateInfos != nullptr) {
1232 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001233 bool has_dynamic_viewport = false;
1234 bool has_dynamic_scissor = false;
1235 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001236 bool has_dynamic_depth_bias = false;
1237 bool has_dynamic_blend_constant = false;
1238 bool has_dynamic_depth_bounds = false;
1239 bool has_dynamic_stencil_compare = false;
1240 bool has_dynamic_stencil_write = false;
1241 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001242 bool has_dynamic_viewport_w_scaling_nv = false;
1243 bool has_dynamic_discard_rectangle_ext = false;
1244 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001245 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001246 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001247 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001248 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001249 if (pCreateInfos[i].pDynamicState != nullptr) {
1250 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1251 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1252 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001253 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1254 if (has_dynamic_viewport == true) {
1255 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1256 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1257 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1258 i);
1259 }
1260 has_dynamic_viewport = true;
1261 }
1262 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1263 if (has_dynamic_scissor == true) {
1264 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1265 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1266 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1267 i);
1268 }
1269 has_dynamic_scissor = true;
1270 }
1271 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1272 if (has_dynamic_line_width == true) {
1273 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1274 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1275 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1276 i);
1277 }
1278 has_dynamic_line_width = true;
1279 }
1280 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1281 if (has_dynamic_depth_bias == true) {
1282 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1283 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1284 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1285 i);
1286 }
1287 has_dynamic_depth_bias = true;
1288 }
1289 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1290 if (has_dynamic_blend_constant == true) {
1291 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1292 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1293 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1294 i);
1295 }
1296 has_dynamic_blend_constant = true;
1297 }
1298 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1299 if (has_dynamic_depth_bounds == true) {
1300 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1301 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1302 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1303 i);
1304 }
1305 has_dynamic_depth_bounds = true;
1306 }
1307 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1308 if (has_dynamic_stencil_compare == true) {
1309 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1310 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1311 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1312 i);
1313 }
1314 has_dynamic_stencil_compare = true;
1315 }
1316 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1317 if (has_dynamic_stencil_write == true) {
1318 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1319 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1320 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1321 i);
1322 }
1323 has_dynamic_stencil_write = true;
1324 }
1325 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1326 if (has_dynamic_stencil_reference == true) {
1327 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1328 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1329 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1330 i);
1331 }
1332 has_dynamic_stencil_reference = true;
1333 }
1334 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1335 if (has_dynamic_viewport_w_scaling_nv == true) {
1336 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1337 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1338 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1339 i);
1340 }
1341 has_dynamic_viewport_w_scaling_nv = true;
1342 }
1343 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1344 if (has_dynamic_discard_rectangle_ext == true) {
1345 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1346 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1347 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1348 i);
1349 }
1350 has_dynamic_discard_rectangle_ext = true;
1351 }
1352 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1353 if (has_dynamic_sample_locations_ext == true) {
1354 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1355 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1356 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1357 i);
1358 }
1359 has_dynamic_sample_locations_ext = true;
1360 }
1361 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1362 if (has_dynamic_exclusive_scissor_nv == true) {
1363 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1364 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1365 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1366 i);
1367 }
1368 has_dynamic_exclusive_scissor_nv = true;
1369 }
1370 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1371 if (has_dynamic_shading_rate_palette_nv == true) {
1372 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1373 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1374 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1375 i);
1376 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001377 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001378 }
1379 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1380 if (has_dynamic_viewport_course_sample_order_nv == true) {
1381 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1382 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1383 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1384 i);
1385 }
1386 has_dynamic_viewport_course_sample_order_nv = true;
1387 }
1388 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1389 if (has_dynamic_line_stipple == true) {
1390 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1391 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1392 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1393 i);
1394 }
1395 has_dynamic_line_stipple = true;
1396 }
Petr Kraus299ba622017-11-24 03:09:03 +01001397 }
1398 }
1399
Peter Chen85366392019-05-14 15:20:11 -04001400 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1401 if ((feedback_struct != nullptr) &&
1402 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001403 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1404 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1405 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1406 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1407 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001408 }
1409
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001410 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001411
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001412 // Collect active stages and other information
1413 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001414 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001415 bool has_eval = false;
1416 bool has_control = false;
1417 if (pCreateInfos[i].pStages != nullptr) {
1418 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1419 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1420
1421 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1422 has_control = true;
1423 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1424 has_eval = true;
1425 }
1426
1427 skip |= validate_string(
1428 "vkCreateGraphicsPipelines",
1429 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1430 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1431 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001432 }
1433
1434 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1435 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1436 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1437 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1438 pCreateInfos[i].pTessellationState,
1439 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1440 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1441
1442 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1443 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1444
1445 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1446 "VkPipelineTessellationDomainOriginStateCreateInfo",
1447 pCreateInfos[i].pTessellationState->pNext,
1448 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1449 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001450 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1451 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001452
1453 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1454 pCreateInfos[i].pTessellationState->flags,
1455 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1456 }
1457
1458 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1459 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1460 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1461 pCreateInfos[i].pInputAssemblyState,
1462 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1463 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1464
1465 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1466 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001467 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001468
1469 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1470 pCreateInfos[i].pInputAssemblyState->flags,
1471 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1472
1473 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1474 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1475 pCreateInfos[i].pInputAssemblyState->topology,
1476 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1477
1478 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1479 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1480 }
1481
1482 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001483 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001484
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001485 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001486 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1487 "vkCreateGraphicsPipelines: pararameter "
1488 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1489 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001490 }
1491
1492 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1493 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1494 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1495 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1496 pCreateInfos[i].pVertexInputState->pNext, 1,
1497 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001498 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1499 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001500 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1501 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001502 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001503 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1504 skip |=
1505 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1506 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1507 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1508 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1509 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1510
1511 skip |= validate_array(
1512 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1513 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1514 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1515 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1516
1517 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1518 for (uint32_t vertexBindingDescriptionIndex = 0;
1519 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1520 ++vertexBindingDescriptionIndex) {
1521 skip |= validate_ranged_enum(
1522 "vkCreateGraphicsPipelines",
1523 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1524 AllVkVertexInputRateEnums,
1525 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1526 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1527 }
1528 }
1529
1530 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1531 for (uint32_t vertexAttributeDescriptionIndex = 0;
1532 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1533 ++vertexAttributeDescriptionIndex) {
1534 skip |= validate_ranged_enum(
1535 "vkCreateGraphicsPipelines",
1536 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1537 AllVkFormatEnums,
1538 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1539 "VUID-VkVertexInputAttributeDescription-format-parameter");
1540 }
1541 }
1542
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001543 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001544 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1545 "vkCreateGraphicsPipelines: pararameter "
1546 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1547 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1548 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001549 }
1550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001551 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001552 skip |=
1553 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1554 "vkCreateGraphicsPipelines: pararameter "
1555 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1556 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1557 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001558 }
1559
1560 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001561 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1562 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001563 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1564 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001565 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1566 "vkCreateGraphicsPipelines: parameter "
1567 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1568 "(%" PRIu32 ") is not distinct.",
1569 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001570 }
1571 vertex_bindings.insert(vertex_bind_desc.binding);
1572
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001573 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001574 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1575 "vkCreateGraphicsPipelines: parameter "
1576 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1577 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1578 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001579 }
1580
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001581 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001582 skip |=
1583 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1584 "vkCreateGraphicsPipelines: parameter "
1585 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1586 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1587 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001588 }
1589 }
1590
Peter Kohautc7d9d392018-07-15 00:34:07 +02001591 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001592 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1593 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001594 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1595 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001596 skip |= LogError(
1597 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001598 "vkCreateGraphicsPipelines: parameter "
1599 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1600 i, d, vertex_attrib_desc.location);
1601 }
1602 attribute_locations.insert(vertex_attrib_desc.location);
1603
1604 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1605 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001606 skip |= LogError(
1607 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001608 "vkCreateGraphicsPipelines: parameter "
1609 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1610 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1611 i, d, vertex_attrib_desc.binding, i);
1612 }
1613
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001614 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001615 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1616 "vkCreateGraphicsPipelines: parameter "
1617 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1618 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1619 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001620 }
1621
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001622 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001623 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1624 "vkCreateGraphicsPipelines: parameter "
1625 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1626 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1627 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001628 }
1629
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001630 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001631 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1632 "vkCreateGraphicsPipelines: parameter "
1633 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1634 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1635 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001636 }
1637 }
1638 }
1639
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001640 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1641 if (has_control && has_eval) {
1642 if (pCreateInfos[i].pTessellationState == nullptr) {
1643 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1644 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1645 "shader stage and a tessellation evaluation shader stage, "
1646 "pCreateInfos[%d].pTessellationState must not be NULL.",
1647 i, i);
1648 } else {
1649 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1650 skip |= validate_struct_pnext(
1651 "vkCreateGraphicsPipelines",
1652 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1653 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1654 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1655 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001656
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001657 skip |= validate_reserved_flags(
1658 "vkCreateGraphicsPipelines",
1659 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1660 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001661
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001662 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1663 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1664 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1665 "vkCreateGraphicsPipelines: invalid parameter "
1666 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1667 "should be >0 and <=%u.",
1668 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1669 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001670 }
1671 }
1672 }
1673
1674 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1675 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1676 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1677 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001678 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1679 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1680 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1681 "].pViewportState (=NULL) is not a valid pointer.",
1682 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001683 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001684 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1685
1686 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001687 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1688 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1689 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1690 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001691 }
1692
Petr Krausa6103552017-11-16 21:21:58 +01001693 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1694 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001695 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1696 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001697 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1698 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001699 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001700 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001701 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001702 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001703 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001704 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1705 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001706 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001707 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1708 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001709
1710 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001711 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001712 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001713 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001714
Dave Houlton142c4cb2018-10-17 15:04:41 -06001715 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1716 pCreateInfos[i].pViewportState->pNext);
1717 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1718 pCreateInfos[i].pViewportState->pNext);
1719 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1720 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001721 const auto vp_swizzle_struct =
1722 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001723 const auto vp_w_scaling_struct =
1724 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001725
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001726 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001727 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001728 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1729 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1730 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1731 ") is not 1.",
1732 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001733 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001734
Petr Krausa6103552017-11-16 21:21:58 +01001735 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001736 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1737 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1738 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1739 ") is not 1.",
1740 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001741 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001742
Dave Houlton142c4cb2018-10-17 15:04:41 -06001743 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1744 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001745 skip |= LogError(
1746 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1747 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1748 "disabled, but pCreateInfos[%" PRIu32
1749 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1750 ") is not 1.",
1751 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001752 }
1753
Jeff Bolz9af91c52018-09-01 21:53:57 -05001754 if (shading_rate_image_struct &&
1755 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001756 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1757 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1758 "disabled, but pCreateInfos[%" PRIu32
1759 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1760 ") is neither 0 nor 1.",
1761 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001762 }
1763
Petr Krausa6103552017-11-16 21:21:58 +01001764 } else { // multiViewport enabled
1765 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001766 skip |= LogError(
1767 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001768 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001769 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001770 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1771 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1772 "].pViewportState->viewportCount (=%" PRIu32
1773 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1774 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001775 }
Petr Krausa6103552017-11-16 21:21:58 +01001776
1777 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001778 skip |= LogError(
1779 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001780 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001781 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001782 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1783 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1784 "].pViewportState->scissorCount (=%" PRIu32
1785 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1786 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001787 }
1788 }
1789
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001790 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001791 skip |=
1792 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1793 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1794 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1795 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001796 }
1797
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001798 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001799 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1800 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1801 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1802 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1803 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001804 }
1805
Petr Krausa6103552017-11-16 21:21:58 +01001806 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001807 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1808 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1809 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1810 "].pViewportState->viewportCount (=%" PRIu32 ").",
1811 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001812 }
1813
Dave Houlton142c4cb2018-10-17 15:04:41 -06001814 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001815 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001816 skip |=
1817 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1818 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1819 ") must be zero or identical to pCreateInfos[%" PRIu32
1820 "].pViewportState->viewportCount (=%" PRIu32 ").",
1821 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001822 }
1823
Dave Houlton142c4cb2018-10-17 15:04:41 -06001824 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001825 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001826 skip |= LogError(
1827 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001828 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1829 "] "
1830 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1831 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1832 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001833 }
1834
Petr Krausa6103552017-11-16 21:21:58 +01001835 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001836 skip |= LogError(
1837 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001838 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1839 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001840 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1841 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001842 }
1843
1844 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001845 skip |= LogError(
1846 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001847 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1848 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001849 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1850 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001851 }
1852
Jeff Bolz3e71f782018-08-29 23:15:45 -05001853 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001854 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1855 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1856 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001857 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-pDynamicStates-02030",
1858 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1859 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1860 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1861 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001862 }
1863
Jeff Bolz9af91c52018-09-01 21:53:57 -05001864 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001865 shading_rate_image_struct->viewportCount > 0 &&
1866 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001867 skip |= LogError(
1868 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-pDynamicStates-02057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001869 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001870 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1871 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001872 i, i);
1873 }
1874
Chris Mayer328d8212018-12-11 14:16:18 +01001875 if (vp_swizzle_struct) {
1876 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1878 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1879 " does "
1880 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1881 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001882 }
1883 }
1884
Petr Krausb3fcdb42018-01-09 22:09:09 +01001885 // validate the VkViewports
1886 if (!has_dynamic_viewport && viewport_state.pViewports) {
1887 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1888 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001889 const char *fn_name = "vkCreateGraphicsPipelines";
1890 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1891 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1892 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001893 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001894 }
1895 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001896
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001897 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001898 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1899 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1900 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1901 "VK_NV_clip_space_w_scaling extension is not enabled.",
1902 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001903 }
1904
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001905 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001906 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1907 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1908 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1909 "VK_EXT_discard_rectangles extension is not enabled.",
1910 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001911 }
1912
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001913 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001914 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1915 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1916 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1917 "VK_EXT_sample_locations extension is not enabled.",
1918 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001919 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001920
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001921 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001922 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1923 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1924 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1925 "VK_NV_scissor_exclusive extension is not enabled.",
1926 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001927 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001928
1929 if (coarse_sample_order_struct &&
1930 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1931 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001932 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1933 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1934 "] "
1935 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1936 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1937 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001938 }
1939
1940 if (coarse_sample_order_struct) {
1941 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001942 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001943 }
1944 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001945
1946 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1947 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001948 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1949 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1950 "] "
1951 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1952 ") "
1953 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1954 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001955 }
1956 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001957 skip |= LogError(
1958 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001959 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1960 "] "
1961 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
1962 i);
1963 }
1964 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001965 }
1966
1967 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001968 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
1969 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
1970 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
1971 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001972 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07001973 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
1974 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
1975 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07001976 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07001977 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07001978 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001979 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001980 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07001981 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001982 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08001983 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
1984 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001985
1986 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001987 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001988 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001989 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001990
1991 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001992 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001993 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
1994 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
1995
1996 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001997 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001998 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
1999 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002000 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002001 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002002
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002003 skip |= validate_flags(
2004 "vkCreateGraphicsPipelines",
2005 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2006 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002007 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002008
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002009 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002010 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002011 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2012 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2013
2014 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002015 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002016 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2017 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2018
2019 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002020 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2021 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2022 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2023 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002024 }
John Zulauf7acac592017-11-06 11:15:53 -07002025 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002026 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002027 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2028 "vkCreateGraphicsPipelines(): parameter "
2029 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2030 i);
John Zulauf7acac592017-11-06 11:15:53 -07002031 }
2032 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2033 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2034 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002035 skip |= LogError(
2036 device,
2037
Dave Houlton413a6782018-05-22 13:01:54 -06002038 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002039 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002040 }
2041 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002042
2043 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2044 pCreateInfos[i].pRasterizationState->pNext);
2045
2046 if (line_state) {
2047 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2048 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2049 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2050 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002051 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2052 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2053 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2054 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002055 }
2056 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2057 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002058 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2059 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2060 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2061 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002062 }
2063 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2064 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002065 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2066 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2067 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2068 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002069 }
2070 }
2071 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2072 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2073 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002074 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2075 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2076 "range [1,256].",
2077 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002078 }
2079 }
2080 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002081 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002082 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2083 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002084 skip |=
2085 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2086 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2087 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2088 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002089 }
2090 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2091 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002092 skip |=
2093 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2094 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2095 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2096 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002097 }
2098 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2099 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002100 skip |=
2101 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2102 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2103 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2104 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002105 }
2106 if (line_state->stippledLineEnable) {
2107 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2108 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002109 skip |=
2110 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2111 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2112 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2113 "stippledRectangularLines feature.",
2114 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002115 }
2116 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2117 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002118 skip |=
2119 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2120 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2121 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2122 "stippledBresenhamLines feature.",
2123 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002124 }
2125 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2126 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002127 skip |=
2128 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2129 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2130 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2131 "stippledSmoothLines feature.",
2132 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002133 }
2134 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2135 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002136 skip |=
2137 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2138 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2139 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2140 "stippledRectangularLines and strictLines features.",
2141 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002142 }
2143 }
2144 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002145 }
2146
Petr Krause91f7a12017-12-14 20:57:36 +01002147 bool uses_color_attachment = false;
2148 bool uses_depthstencil_attachment = false;
2149 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002150 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002151 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2152 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002153 const auto &subpasses_uses = subpasses_uses_it->second;
2154 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2155 uses_color_attachment = true;
2156 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2157 uses_depthstencil_attachment = true;
2158 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002159 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002160 }
2161
2162 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002163 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002164 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002165 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002166 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002167 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002168
2169 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002170 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002171 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002172 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002173
2174 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002175 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002176 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2177 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2178
2179 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002180 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002181 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2182 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2183
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->depthCompareOp", ParameterName::IndexVector{i}),
2187 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002188 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002189
2190 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002191 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002192 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2193 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2194
2195 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002196 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002197 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2198 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2199
2200 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002201 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002202 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2203 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002204 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205
2206 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002207 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2209 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002210 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211
2212 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002213 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002214 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2215 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002216 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002217
2218 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002219 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002220 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2221 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002222 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002223
2224 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002225 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002226 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2227 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002228 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229
2230 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002232 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2233 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002234 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002235
2236 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002237 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002238 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2239 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002240 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002241
2242 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002243 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2245 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002246 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002247
2248 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002249 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2250 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2251 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2252 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002253 }
2254 }
2255
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002256 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2257 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2258
Petr Krause91f7a12017-12-14 20:57:36 +01002259 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002260 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2261 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2262 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2263 pCreateInfos[i].pColorBlendState,
2264 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2265 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2266
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002267 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002268 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002269 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2270 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2271 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002272 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002273 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2274 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275
2276 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002277 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002278 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002279 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002280
2281 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002282 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002283 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2284 pCreateInfos[i].pColorBlendState->logicOpEnable);
2285
2286 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002287 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002288 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2289 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002290 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002291 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002292
2293 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2294 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2295 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002296 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002297 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2298 ParameterName::IndexVector{i, attachmentIndex}),
2299 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2300
2301 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002302 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002303 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2304 ParameterName::IndexVector{i, attachmentIndex}),
2305 "VkBlendFactor", AllVkBlendFactorEnums,
2306 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002307 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002308
2309 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002310 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002311 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2312 ParameterName::IndexVector{i, attachmentIndex}),
2313 "VkBlendFactor", AllVkBlendFactorEnums,
2314 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002315 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002316
2317 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002318 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002319 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2320 ParameterName::IndexVector{i, attachmentIndex}),
2321 "VkBlendOp", AllVkBlendOpEnums,
2322 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002323 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002324
2325 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002326 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002327 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2328 ParameterName::IndexVector{i, attachmentIndex}),
2329 "VkBlendFactor", AllVkBlendFactorEnums,
2330 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002331 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332
2333 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002334 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002335 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2336 ParameterName::IndexVector{i, attachmentIndex}),
2337 "VkBlendFactor", AllVkBlendFactorEnums,
2338 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002339 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002340
2341 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002342 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002343 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2344 ParameterName::IndexVector{i, attachmentIndex}),
2345 "VkBlendOp", AllVkBlendOpEnums,
2346 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002347 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348
2349 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002350 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2352 ParameterName::IndexVector{i, attachmentIndex}),
2353 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2354 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002355 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356 }
2357 }
2358
2359 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002360 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2361 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2362 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2363 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364 }
2365
2366 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2367 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2368 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002369 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002370 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002371 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2372 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002373 }
2374 }
2375 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002376
Petr Kraus9752aae2017-11-24 03:05:50 +01002377 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2378 if (pCreateInfos[i].basePipelineIndex != -1) {
2379 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002380 skip |=
2381 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002382 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002383 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002384 "and pCreateInfos->basePipelineIndex is not -1.",
2385 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002386 }
2387 }
2388
Petr Kraus9752aae2017-11-24 03:05:50 +01002389 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2390 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002391 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002392 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002393 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002394 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2395 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002397 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002398 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002399 skip |=
2400 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2401 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2402 "index into the pCreateInfos array, of size %d.",
2403 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002404 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002405 }
2406 }
2407
sfricke-samsung898cf222020-05-15 23:10:19 -07002408 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2409 skip |= LogError(
2410 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2411 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2412 i);
2413 }
2414
Petr Kraus9752aae2017-11-24 03:05:50 +01002415 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002416 if (!device_extensions.vk_nv_fill_rectangle) {
2417 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2418 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002419 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2420 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2421 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2422 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002423 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2424 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002425 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2426 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002427 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2428 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2429 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002430 }
2431 } else {
2432 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2433 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2434 (physical_device_features.fillModeNonSolid == false)) {
2435 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002436 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2437 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002438 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2439 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2440 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002441 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002442 }
Petr Kraus299ba622017-11-24 03:09:03 +01002443
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002444 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002445 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002446 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2447 "The line width state is static (pCreateInfos[%" PRIu32
2448 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2449 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2450 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2451 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002452 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002453 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002454 }
2455 }
2456
2457 return skip;
2458}
2459
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002460bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2461 uint32_t createInfoCount,
2462 const VkComputePipelineCreateInfo *pCreateInfos,
2463 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002464 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002465 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002467 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002468 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002469 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002470 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2471 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002472 skip |=
2473 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2474 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2475 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2476 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002477 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002478
2479 // Make sure compute stage is selected
2480 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002481 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2482 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2483 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002484 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002486 return skip;
2487}
2488
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002489bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002490 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002492
2493 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002494 const auto &features = physical_device_features;
2495 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002496
John Zulauf71968502017-10-26 13:51:15 -06002497 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2498 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002499 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2500 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2501 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2502 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002503 }
2504
2505 // Anistropy cannot be enabled in sampler unless enabled as a feature
2506 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002507 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2508 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2509 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002510 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002511 }
John Zulauf71968502017-10-26 13:51:15 -06002512
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002513 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2514 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002515 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2516 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2517 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2518 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002519 }
2520 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002521 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2522 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2523 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2524 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002525 }
2526 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002527 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2528 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2529 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2530 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002531 }
2532 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2533 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2534 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2535 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002536 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2537 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2538 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2539 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2540 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2541 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002542 }
2543 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002544 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2545 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2546 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002547 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002548 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002549 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2550 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2551 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002552 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002553 }
2554
2555 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2556 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002557 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2558 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002559 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2560 if (sampler_reduction != nullptr) {
2561 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2562 skip |= LogError(
2563 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2564 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2565 }
2566 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002567 }
2568
2569 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2570 // valid VkBorderColor value
2571 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2572 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2573 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002574 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2575 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002576 }
2577
2578 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2579 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002580 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002581 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2582 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2583 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002584 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002585 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2586 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2587 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002588 }
John Zulauf275805c2017-10-26 15:34:49 -06002589
2590 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002591 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002592 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2593 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002594 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2595 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2596 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002597 }
2598 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002599
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002600 // Check for valid Lod range
2601 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002602 skip |=
2603 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2604 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002605 }
2606
2607 // Check mipLodBias to device limit
2608 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002609 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2610 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2611 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002612 }
2613
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002614 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2615 if (sampler_conversion != nullptr) {
2616 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2617 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2618 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2619 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002620 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002621 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002622 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2623 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2624 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2625 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2626 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2627 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2628 }
2629 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002630
2631 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2632 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2633 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2634 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2635 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2636 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2637 }
2638 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2639 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2640 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2641 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2642 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2643 }
2644 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2645 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2646 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2647 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2648 pCreateInfo->minLod, pCreateInfo->maxLod);
2649 }
2650 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2651 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2652 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2653 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2654 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2655 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2656 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2657 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2658 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2659 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2660 }
2661 if (pCreateInfo->anisotropyEnable) {
2662 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2663 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2664 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2665 }
2666 if (pCreateInfo->compareEnable) {
2667 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2668 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2669 "pCreateInfo->compareEnable must be VK_FALSE");
2670 }
2671 if (pCreateInfo->unnormalizedCoordinates) {
2672 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2673 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2674 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2675 }
2676 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002677 }
2678
Tony-LunarG7337b312020-04-15 16:40:25 -06002679 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2680 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2681 if (!device_extensions.vk_ext_custom_border_color) {
2682 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2683 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2684 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2685 }
2686 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2687 if (!custom_create_info) {
2688 skip |=
2689 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2690 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2691 "struct in pNext chain.\n",
2692 string_VkBorderColor(pCreateInfo->borderColor));
2693 } else {
2694 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2695 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2696 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2697 !FormatIsSampledFloat(custom_create_info->format)))) {
2698 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2699 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2700 "whose type does not match\n",
2701 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2702 ;
2703 }
2704 }
2705 }
2706
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002707 return skip;
2708}
2709
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002710bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2711 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2712 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002713 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002714 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002715
2716 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2717 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2718 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2719 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002720 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2721 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2722 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2723 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2724 ++descriptor_index) {
2725 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002726 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002727 "vkCreateDescriptorSetLayout: required parameter "
2728 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2729 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002730 }
2731 }
2732 }
2733
2734 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2735 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2736 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002737 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2738 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2739 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2740 "values.",
2741 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002742 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002743
2744 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2745 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2746 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2747 skip |=
2748 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2749 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2750 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2751 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2752 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2753 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002754 }
2755 }
2756 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002757 return skip;
2758}
2759
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002760bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2761 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002762 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002763 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2764 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2765 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002766 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2767 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002768}
2769
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002770bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2771 const VkWriteDescriptorSet *pDescriptorWrites,
2772 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002773 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002774
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002775 if (pDescriptorWrites != NULL) {
2776 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2777 // descriptorCount must be greater than 0
2778 if (pDescriptorWrites[i].descriptorCount == 0) {
2779 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002780 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2781 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 }
2783
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002784 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2785 if (validateDstSet) {
2786 // dstSet must be a valid VkDescriptorSet handle
2787 skip |= validate_required_handle(vkCallingFunction,
2788 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2789 pDescriptorWrites[i].dstSet);
2790 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002791
2792 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2793 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2794 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2795 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2796 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2797 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2798 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002799 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2800 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002801 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002802 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2803 "%s(): if pDescriptorWrites[%d].descriptorType is "
2804 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2805 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2806 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2807 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002808 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2809 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002810 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2811 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002812 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2813 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002814 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2816 ParameterName::IndexVector{i, descriptor_index}),
2817 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002818 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002819 }
2820 }
2821 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2822 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2823 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2824 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2825 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2826 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2827 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002828 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002829 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002830 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2831 "%s(): if pDescriptorWrites[%d].descriptorType is "
2832 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2833 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2834 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2835 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002836 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002837 const auto *robustness2_features =
2838 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2839 if (robustness2_features && robustness2_features->nullDescriptor) {
2840 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2841 ++descriptorIndex) {
2842 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2843 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2844 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2845 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2846 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2847 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2848 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2849 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2850 }
2851 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 }
2853 }
2854 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2855 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002856 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002857 }
2858
2859 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2860 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002861 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002862 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2863 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2864 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002865 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002866 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2867 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2868 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2869 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002870 }
2871 }
2872 }
2873 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2874 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002875 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2877 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2878 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002879 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002880 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2881 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2882 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2883 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002884 }
2885 }
2886 }
2887 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002888 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2889 // or VkWriteDescriptorSetInlineUniformBlockEX
2890 if (pDescriptorWrites[i].pNext) {
2891 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
2892 const auto *pNext_struct =
2893 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
2894 if (!pNext_struct || (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
2895 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2896 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2897 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2898 "accelerationStructureCount %d member equals descriptorCount %d.",
2899 vkCallingFunction, pNext_struct ? pNext_struct->accelerationStructureCount : -1,
2900 pDescriptorWrites[i].descriptorCount);
2901 }
2902 // further checks only if we have right structtype
2903 if (pNext_struct) {
2904 if (pNext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
2905 skip |= LogError(
2906 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2907 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2908 ".",
2909 vkCallingFunction, pNext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
2910 }
2911 if (pNext_struct->accelerationStructureCount == 0) {
2912 skip |= LogError(
2913 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2914 "%s(): accelerationStructureCount must be greater than 0 .");
2915 }
2916 }
2917 }
2918 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002919 }
2920 }
2921 return skip;
2922}
2923
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002924bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2925 const VkWriteDescriptorSet *pDescriptorWrites,
2926 uint32_t descriptorCopyCount,
2927 const VkCopyDescriptorSet *pDescriptorCopies) const {
2928 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2929}
2930
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002931bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002932 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002933 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002934 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2935}
2936
2937bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002938 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002939 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002940 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2941}
2942
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002943bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2944 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002945 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002946 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002947
2948 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2949 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2950 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002951 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2952 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002953 return skip;
2954}
2955
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002956bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002957 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002958 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002959
2960 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
2961 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002962 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
2963
Petr Krause7bb9e82019-08-11 21:34:43 +02002964 // Implicit VUs
2965 // validate only sType here; pointer has to be validated in core_validation
2966 const bool kNotRequired = false;
2967 const char *kNoVUID = nullptr;
2968 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
2969 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
2970 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002971
Petr Krause7bb9e82019-08-11 21:34:43 +02002972 if (pInfo) {
2973 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
2974 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
2975 skip |= validate_struct_pnext(
2976 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
2977 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08002978 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
2979 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002980
Petr Krause7bb9e82019-08-11 21:34:43 +02002981 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002982
Petr Krause7bb9e82019-08-11 21:34:43 +02002983 // Explicit VUs
2984 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002985 skip |= LogError(
2986 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02002987 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
2988 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002989 }
Petr Krause7bb9e82019-08-11 21:34:43 +02002990
2991 if (physical_device_features.inheritedQueries) {
2992 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02002993 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06002994 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02002995 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02002996 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02002997 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02002998 }
2999
3000 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003001 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003002 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003003 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003004 } else { // !pipelineStatisticsQuery
3005 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3006 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003007 }
Petr Kraus139757b2019-08-15 17:19:33 +02003008
3009 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3010 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003011 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003012 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3013 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003014 skip |= LogError(
3015 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003016 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3017 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3018 }
3019 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020 }
3021
3022 return skip;
3023}
3024
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003025bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003026 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003027 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003028
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003029 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003030 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003031 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3032 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3033 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003034 }
3035 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003036 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3037 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3038 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003039 }
3040 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003041 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003042 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003043 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3044 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3045 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3046 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 }
3048 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003049
3050 if (pViewports) {
3051 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3052 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003053 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003054 skip |= manual_PreCallValidateViewport(
3055 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003056 }
3057 }
3058
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003059 return skip;
3060}
3061
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003062bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003063 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003064 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003065
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003066 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003067 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003068 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3069 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3070 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003071 }
3072 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003073 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3074 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3075 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003076 }
3077 } else { // multiViewport enabled
3078 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003079 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003080 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3081 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3082 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3083 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003084 }
3085 }
3086
Petr Kraus6260f0a2018-02-27 21:15:55 +01003087 if (pScissors) {
3088 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3089 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003090
Petr Kraus6260f0a2018-02-27 21:15:55 +01003091 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003092 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3093 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3094 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003095 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003096
Petr Kraus6260f0a2018-02-27 21:15:55 +01003097 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003098 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3099 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3100 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003101 }
3102
3103 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3104 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003105 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3106 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3107 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3108 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003109 }
3110
3111 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3112 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3114 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3115 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3116 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003117 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003118 }
3119 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003120
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003121 return skip;
3122}
3123
Jeff Bolz5c801d12019-10-09 10:38:45 -05003124bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003125 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003126
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003127 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003128 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3129 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003130 }
3131
3132 return skip;
3133}
3134
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003135bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003136 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003138 if (vertexCount == 0) {
3139 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3140 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003141 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 }
3143
3144 if (instanceCount == 0) {
3145 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3146 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003147 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003148 }
3149 return skip;
3150}
3151
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003152bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003153 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003154 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003155
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003156 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003157 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3158 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003159 }
3160 return skip;
3161}
3162
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003163bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003164 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003165 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003166 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003167 skip |=
3168 LogError(device, kVUID_PVError_DeviceFeature,
3169 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003170 }
3171 return skip;
3172}
3173
sfricke-samsungf692b972020-05-02 08:00:45 -07003174bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3175 VkDeviceSize countBufferOffset, bool khr) const {
3176 bool skip = false;
3177 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3178 if (offset & 3) {
3179 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3180 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3181 }
3182
3183 if (countBufferOffset & 3) {
3184 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3185 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3186 countBufferOffset);
3187 }
3188 return skip;
3189}
3190
3191bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3192 VkDeviceSize offset, VkBuffer countBuffer,
3193 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3194 uint32_t stride) const {
3195 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3196}
3197
3198bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3199 VkDeviceSize offset, VkBuffer countBuffer,
3200 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3201 uint32_t stride) const {
3202 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3203}
3204
3205bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3206 VkDeviceSize countBufferOffset, bool khr) const {
3207 bool skip = false;
3208 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3209 if (offset & 3) {
3210 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3211 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3212 }
3213
3214 if (countBufferOffset & 3) {
3215 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3216 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3217 countBufferOffset);
3218 }
3219 return skip;
3220}
3221
3222bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3223 VkDeviceSize offset, VkBuffer countBuffer,
3224 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3225 uint32_t stride) const {
3226 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3227}
3228
3229bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3230 VkDeviceSize offset, VkBuffer countBuffer,
3231 VkDeviceSize countBufferOffset,
3232 uint32_t maxDrawCount, uint32_t stride) const {
3233 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3234}
3235
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003236bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3237 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003238 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003239 bool skip = false;
3240 for (uint32_t rect = 0; rect < rectCount; rect++) {
3241 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003242 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3243 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003244 }
sfricke-samsung10867682020-04-25 02:20:39 -07003245 if (pRects[rect].rect.extent.width == 0) {
3246 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3247 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3248 }
3249 if (pRects[rect].rect.extent.height == 0) {
3250 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3251 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3252 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003253 }
3254 return skip;
3255}
3256
Andrew Fobel3abeb992020-01-20 16:33:22 -05003257bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3258 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3259 VkImageFormatProperties2 *pImageFormatProperties,
3260 const char *apiName) const {
3261 bool skip = false;
3262
3263 if (pImageFormatInfo != nullptr) {
3264 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3265 if (image_stencil_struct != nullptr) {
3266 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3267 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3268 // No flags other than the legal attachment bits may be set
3269 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3270 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003271 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3272 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3273 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3274 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3275 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003276 }
3277 }
3278 }
3279 }
3280
3281 return skip;
3282}
3283
3284bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3285 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3286 VkImageFormatProperties2 *pImageFormatProperties) const {
3287 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3288 "vkGetPhysicalDeviceImageFormatProperties2");
3289}
3290
3291bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3292 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3293 VkImageFormatProperties2 *pImageFormatProperties) const {
3294 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3295 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3296}
3297
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003298bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3299 VkImageLayout srcImageLayout, VkImage dstImage,
3300 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003301 const VkImageCopy *pRegions) 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, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003314 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003315 }
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, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003319 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003320 }
3321 }
3322 return skip;
3323}
3324
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003325bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3326 VkImageLayout srcImageLayout, VkImage dstImage,
3327 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003328 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003329 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003330
Dave Houltonf5217612018-02-02 16:18:52 -07003331 VkImageAspectFlags legal_aspect_flags =
3332 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 -07003333 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003334 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3335 }
3336
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003337 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003338 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003339 skip |= LogError(
3340 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003341 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3342 }
Dave Houltonf5217612018-02-02 16:18:52 -07003343 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003344 skip |= LogError(
3345 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003346 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3347 }
3348 }
3349 return skip;
3350}
3351
sfricke-samsung3999ef62020-02-09 17:05:59 -08003352bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3353 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3354 bool skip = false;
3355
3356 if (pRegions != nullptr) {
3357 for (uint32_t i = 0; i < regionCount; i++) {
3358 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003359 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3360 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003361 }
3362 }
3363 }
3364 return skip;
3365}
3366
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003367bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3368 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003369 uint32_t regionCount,
3370 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003371 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003372
Dave Houltonf5217612018-02-02 16:18:52 -07003373 VkImageAspectFlags legal_aspect_flags =
3374 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 -07003375 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003376 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3377 }
3378
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003379 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003380 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003381 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3382 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3383 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003384 }
3385 }
3386 return skip;
3387}
3388
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003389bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3390 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003391 uint32_t regionCount,
3392 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003393 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003394
Dave Houltonf5217612018-02-02 16:18:52 -07003395 VkImageAspectFlags legal_aspect_flags =
3396 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 -07003397 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003398 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3399 }
3400
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003401 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003402 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003403 skip |= LogError(
3404 device, kVUID_PVError_UnrecognizedValue,
3405 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3406 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 }
3408 }
3409 return skip;
3410}
3411
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003412bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003413 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3414 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003415 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003416
3417 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003418 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3419 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3420 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003421 }
3422
3423 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003424 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3425 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3426 "), must be greater than zero and less than or equal to 65536.",
3427 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003429 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3430 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3431 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003432 }
3433 return skip;
3434}
3435
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003436bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003437 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003438 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439
3440 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003441 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3442 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3443 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003444 }
3445
3446 if (size != VK_WHOLE_SIZE) {
3447 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003448 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003449 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3450 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003451 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003452 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3453 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003454 }
3455 }
3456 return skip;
3457}
3458
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003459bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003460 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003461 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003462 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003463
3464 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003465 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3466 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3467 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3468 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003469 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3470 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3471 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003472 }
3473
3474 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3475 // queueFamilyIndexCount uint32_t values
3476 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003477 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3478 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3479 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3480 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003481 }
3482 }
3483
Dave Houlton413a6782018-05-22 13:01:54 -06003484 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003485 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003486 }
3487
3488 return skip;
3489}
3490
Jeff Bolz5c801d12019-10-09 10:38:45 -05003491bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003492 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003493
3494 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003495 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3496 if (present_regions) {
3497 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003498 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003499 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3500 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003501 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3502 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3503 "extension swapchainCount is %i. These values must be equal.",
3504 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003505 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003506 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003507 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3508 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003509 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3510 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3511 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003512 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003513 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003514 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003515 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003516 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003517 }
3518 }
3519
3520 return skip;
3521}
3522
3523#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003524bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3525 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3526 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003527 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003528 bool skip = false;
3529
3530 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003531 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3532 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533 }
3534
3535 return skip;
3536}
3537#endif // VK_USE_PLATFORM_WIN32_KHR
3538
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003539bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003540 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003541 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003542 bool skip = false;
3543
3544 if (pCreateInfo) {
3545 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003546 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3547 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003548 }
3549
3550 if (pCreateInfo->pPoolSizes) {
3551 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3552 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003553 skip |= LogError(
3554 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003555 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003556 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003557 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3558 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003559 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3560 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3561 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3562 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3563 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003564 }
Petr Krausc8655be2017-09-27 18:56:51 +02003565 }
3566 }
3567 }
3568
3569 return skip;
3570}
3571
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003572bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003573 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003574 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003575
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003576 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003577 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003578 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3579 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3580 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003581 }
3582
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003583 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003584 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003585 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3586 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3587 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003588 }
3589
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003590 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003591 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003592 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3593 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3594 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003595 }
3596
3597 return skip;
3598}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003599
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003600bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003601 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003602 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003603
3604 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003605 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3606 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003607 }
3608 return skip;
3609}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003610
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003611bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3612 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003613 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003614 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003615
3616 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003617 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003618 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003619 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3620 "vkCmdDispatch(): baseGroupX (%" PRIu32
3621 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3622 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003623 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003624 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3625 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3626 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3627 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003628 }
3629
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003630 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003631 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003632 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3633 "vkCmdDispatch(): baseGroupY (%" PRIu32
3634 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3635 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003636 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003637 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3638 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3639 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3640 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003641 }
3642
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003643 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003644 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3646 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3647 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3648 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003649 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003650 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3651 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3652 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3653 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003654 }
3655
3656 return skip;
3657}
3658
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003659bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3660 VkPipelineBindPoint pipelineBindPoint,
3661 VkPipelineLayout layout, uint32_t set,
3662 uint32_t descriptorWriteCount,
3663 const VkWriteDescriptorSet *pDescriptorWrites) const {
3664 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3665}
3666
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003667bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3668 uint32_t firstExclusiveScissor,
3669 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003670 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003671 bool skip = false;
3672
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003673 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003674 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003675 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003676 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3677 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3678 ") is not 0.",
3679 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003680 }
3681 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003682 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003683 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3684 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3685 ") is not 1.",
3686 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003687 }
3688 } else { // multiViewport enabled
3689 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003690 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003691 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3692 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3693 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3694 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003695 }
3696 }
3697
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003698 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003699 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3700 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3701 ") must be less than maxViewports (=%" PRIu32 ").",
3702 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003703 }
3704
3705 if (pExclusiveScissors) {
3706 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3707 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3708
3709 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003710 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3711 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3712 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003713 }
3714
3715 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3717 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3718 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003719 }
3720
3721 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3722 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003723 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3724 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3725 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3726 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003727 }
3728
3729 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3730 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003731 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3732 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3733 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3734 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003735 }
3736 }
3737 }
3738
3739 return skip;
3740}
3741
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003742bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3743 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003744 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003745 bool skip = false;
3746 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003747 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3748 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3749 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003750 } else {
3751 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3752 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003753 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3754 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3755 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3756 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003757 }
3758 }
3759
3760 return skip;
3761}
3762
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003763bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3764 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003765 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003766 bool skip = false;
3767
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003768 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003769 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003770 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3772 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3773 ") is not 0.",
3774 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003775 }
3776 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003777 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003778 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3779 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3780 ") is not 1.",
3781 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003782 }
3783 }
3784
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003785 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003786 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3787 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3788 ") must be less than maxViewports (=%" PRIu32 ").",
3789 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003790 }
3791
3792 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003793 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003794 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3795 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3796 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3797 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003798 }
3799
3800 return skip;
3801}
3802
Jeff Bolz5c801d12019-10-09 10:38:45 -05003803bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3804 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3805 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003806 bool skip = false;
3807
Dave Houlton142c4cb2018-10-17 15:04:41 -06003808 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003809 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3810 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3811 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003812 }
3813
3814 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003815 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003816 }
3817
3818 return skip;
3819}
3820
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003821bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003822 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003823 bool skip = false;
3824
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003825 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003826 skip |= LogError(
3827 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003828 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3829 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003830 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003831 }
3832
3833 return skip;
3834}
3835
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003836bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3837 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003838 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003839 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003840 static const int condition_multiples = 0b0011;
3841 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003842 skip |= LogError(
3843 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003844 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003845 }
Lockee1c22882019-06-10 16:02:54 -06003846 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003847 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3848 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3849 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3850 stride);
Lockee1c22882019-06-10 16:02:54 -06003851 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003852 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003853 skip |= LogError(
3854 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3855 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003856 }
3857
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003858 return skip;
3859}
3860
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003861bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3862 VkDeviceSize offset, VkBuffer countBuffer,
3863 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003864 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003865 bool skip = false;
3866
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003867 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003868 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3869 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3870 "), is not a multiple of 4.",
3871 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003872 }
3873
3874 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003875 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3876 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3877 "), is not a multiple of 4.",
3878 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003879 }
3880
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003881 return skip;
3882}
3883
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003884bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003885 const VkAllocationCallbacks *pAllocator,
3886 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003887 bool skip = false;
3888
3889 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3890 if (pCreateInfo != nullptr) {
3891 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3892 // VkQueryPipelineStatisticFlagBits values
3893 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3894 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003895 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3896 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3897 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3898 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003899 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003900 if (pCreateInfo->queryCount == 0) {
3901 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3902 "vkCreateQueryPool(): queryCount must be greater than zero.");
3903 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003904 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003905 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003906}
3907
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003908bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3909 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003910 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003911 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3912 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003913}
3914
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003915void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003916 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3917 VkResult result) {
3918 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003919 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003920}
3921
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003922void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003923 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3924 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003925 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003926 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003927 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003928}
3929
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003930void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3931 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003932 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003933 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003934 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003935}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003936
3937bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003938 const VkAllocationCallbacks *pAllocator,
3939 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003940 bool skip = false;
3941
3942 if (pAllocateInfo) {
3943 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3944 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003945 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3946 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003947 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003948
3949 VkMemoryAllocateFlags flags = 0;
3950 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3951 if (flags_info) {
3952 flags = flags_info->flags;
3953 }
3954
3955 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3956 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3957 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003958 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3959 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
3960 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003961 }
3962
3963#ifdef VK_USE_PLATFORM_WIN32_KHR
3964 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
3965#endif
3966 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
3967 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
3968#ifdef VK_USE_PLATFORM_ANDROID_KHR
3969 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
3970#endif
3971
3972 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003973 skip |= LogError(
3974 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003975 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
3976 }
3977 if (
3978#ifdef VK_USE_PLATFORM_WIN32_KHR
3979 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
3980#endif
3981 (import_memory_fd && import_memory_fd->handleType) ||
3982#ifdef VK_USE_PLATFORM_ANDROID_KHR
3983 (import_memory_ahb && import_memory_ahb->buffer) ||
3984#endif
3985 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003986 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
3987 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003988 }
3989 }
3990
3991 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07003992 VkBool32 capture_replay = false;
3993 VkBool32 buffer_device_address = false;
3994 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
3995 if (vulkan_12_features) {
3996 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
3997 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
3998 } else {
3999 const auto *bda_features =
4000 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4001 if (bda_features) {
4002 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4003 buffer_device_address = bda_features->bufferDeviceAddress;
4004 }
4005 }
4006 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004007 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4008 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4009 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004010 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004011 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004012 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4013 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004014 }
4015 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004016 }
4017 return skip;
4018}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004019
Jason Macnak192fa0e2019-07-26 15:07:16 -07004020bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004021 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004022 bool skip = false;
4023
4024 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4025 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4026 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004027 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004028 } else {
4029 uint32_t vertex_component_size = 0;
4030 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4031 vertex_component_size = 4;
4032 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4033 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4034 vertex_component_size = 2;
4035 }
4036 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004037 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004038 }
4039 }
4040
4041 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4042 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004043 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004044 } else {
4045 uint32_t index_element_size = 0;
4046 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4047 index_element_size = 4;
4048 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4049 index_element_size = 2;
4050 }
4051 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004052 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004053 }
4054 }
4055 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4056 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004057 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004058 }
4059 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004061 }
4062 }
4063
4064 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004065 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004066 }
4067
4068 return skip;
4069}
4070
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004071bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4072 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004073 bool skip = false;
4074
4075 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004076 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004077 }
4078 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004079 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004080 }
4081
4082 return skip;
4083}
4084
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004085bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4086 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004087 bool skip = false;
4088 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004089 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004090 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004091 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004092 }
4093 return skip;
4094}
4095
4096bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004097 VkAccelerationStructureNV object_handle, const char *func_name,
4098 bool isCmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004099 bool skip = false;
4100 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004101 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4102 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4103 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004104 }
4105 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004106 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4107 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4108 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004109 }
4110 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4111 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004112 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4113 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4114 "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 -07004115 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004116 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004117 skip |= LogError(object_handle,
4118 isCmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4119 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004120 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4121 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004122 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004123 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004124 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4125 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4126 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004127 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004128 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004129 uint64_t total_triangle_count = 0;
4130 for (uint32_t i = 0; i < info.geometryCount; i++) {
4131 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004132
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004133 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004134
Jason Macnak5c954952019-07-09 15:46:12 -07004135 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4136 continue;
4137 }
4138 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4139 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004140 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004141 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4142 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4143 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004144 }
4145 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004146 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4147 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4148 for (uint32_t i = 1; i < info.geometryCount; i++) {
4149 const VkGeometryNV &geometry = info.pGeometries[i];
4150 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004151 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004152 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4153 "info.pGeometries[0].geometryType.",
4154 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004155 }
4156 }
4157 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004158 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4159 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4160 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4161 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4162 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4163 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4164 }
4165 }
4166 skip |=
4167 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
4168 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-03486");
Jason Macnak5c954952019-07-09 15:46:12 -07004169 return skip;
4170}
4171
Ricardo Garciaa4935972019-02-21 17:43:18 +01004172bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4173 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004174 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004175 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004176 if (pCreateInfo) {
4177 if ((pCreateInfo->compactedSize != 0) &&
4178 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004179 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4180 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4181 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4182 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004183 }
Jason Macnak5c954952019-07-09 15:46:12 -07004184
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004185 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004186 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004187 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004188 return skip;
4189}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004190
Jeff Bolz5c801d12019-10-09 10:38:45 -05004191bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4192 const VkAccelerationStructureInfoNV *pInfo,
4193 VkBuffer instanceData, VkDeviceSize instanceOffset,
4194 VkBool32 update, VkAccelerationStructureNV dst,
4195 VkAccelerationStructureNV src, VkBuffer scratch,
4196 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004197 bool skip = false;
4198
4199 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004200 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004201 }
4202
4203 return skip;
4204}
4205
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004206bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4207 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4208 VkAccelerationStructureKHR *pAccelerationStructure) const {
4209 bool skip = false;
4210
4211 if (pCreateInfo) {
4212 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4213 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4214 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4215 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4216 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4217 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4218 i);
4219 }
4220 }
4221
4222 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4223 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4224 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4225 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4226 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4227 i);
4228 }
4229 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004230 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4231 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4232 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4233 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4234 skip |= LogError(
4235 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4236 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4237 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4238 }
4239 }
4240 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4241 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4242 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4243 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4244 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4245 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4246 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4247 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4248 }
4249 }
4250 }
4251
4252 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4253 pCreateInfo->maxGeometryCount != 1) {
4254 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4255 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4256 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004257 }
4258
4259 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4260 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4261 skip |= LogError(
4262 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4263 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4264 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4265 }
4266
4267 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4268 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4269 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4270 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4271 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4272 }
4273
4274 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4275 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4276 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4277 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4278 if (geometry_type != first_geometry_type) {
4279 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4280 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4281 "pGeometryInfos[0].geometryType.",
4282 i);
4283 }
4284 }
4285 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004286 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4287 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4288 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4289 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4290 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4291 "maxGeometryCount %d.",
4292 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4293 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004294 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004295 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4296 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4297 if (pCreateInfo->deviceAddress != 0) {
4298 skip |=
4299 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4300 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4301 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4302 }
4303 }
sourav parmar83c31b12020-05-06 12:30:54 -07004304 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4305 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4306 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4307 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004308 return skip;
4309}
4310
Jason Macnak5c954952019-07-09 15:46:12 -07004311bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4312 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004313 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004314 bool skip = false;
4315 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004316 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4317 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004318 }
4319 return skip;
4320}
4321
Peter Chen85366392019-05-14 15:20:11 -04004322bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4323 uint32_t createInfoCount,
4324 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4325 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004326 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004327 bool skip = false;
4328
4329 for (uint32_t i = 0; i < createInfoCount; i++) {
4330 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4331 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004332 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004333 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4334 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4335 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4336 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004337 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004338
4339 const auto *pipeline_cache_contol_features =
4340 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4341 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4342 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4343 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4344 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4345 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4346 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4347 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4348 }
4349 }
4350
sourav parmarf4a78252020-04-10 13:04:21 -07004351 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4352 skip |=
4353 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4354 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4355 }
4356 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4357 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4358 skip |=
4359 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4360 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4361 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4362 }
4363 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4364 if (pCreateInfos[i].basePipelineIndex != -1) {
4365 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4366 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4367 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4368 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4369 "and pCreateInfos->basePipelineIndex is not -1.");
4370 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004371 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4372 skip |=
4373 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4374 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4375 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4376 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4377 "that element.");
4378 }
sourav parmarf4a78252020-04-10 13:04:21 -07004379 }
4380 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4381 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4382 skip |=
4383 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4384 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4385 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4386 "commands pCreateInfos parameter.");
4387 }
4388 } else {
4389 if (pCreateInfos[i].basePipelineIndex != -1) {
4390 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4391 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4392 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4393 }
4394 }
4395 }
4396 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4397 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4398 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4399 }
4400 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4401 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4402 "vkCreateRayTracingPipelinesNV: flags must not include "
4403 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4404 }
4405 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4406 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4407 "vkCreateRayTracingPipelinesNV: flags must not include "
4408 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4409 }
4410 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4411 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4412 "vkCreateRayTracingPipelinesNV: flags must not include "
4413 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4414 }
4415 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4416 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4417 "vkCreateRayTracingPipelinesNV: flags must not include "
4418 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4419 }
4420 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4421 skip |= LogError(
4422 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4423 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4424 }
4425 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4426 skip |= LogError(
4427 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4428 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4429 }
Peter Chen85366392019-05-14 15:20:11 -04004430 }
4431
4432 return skip;
4433}
4434
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004435bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4436 uint32_t createInfoCount,
4437 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4438 const VkAllocationCallbacks *pAllocator,
4439 VkPipeline *pPipelines) const {
4440 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004441 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4442 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4443 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4444 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4445 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004446 for (uint32_t i = 0; i < createInfoCount; i++) {
4447 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4448 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4449 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4450 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4451 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4452 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4453 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4454 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004455 const auto *pipeline_cache_contol_features =
4456 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4457 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4458 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4459 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4460 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4461 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4462 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4463 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4464 }
4465 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004466 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4467 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4468 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4469 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4470 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4471 }
4472 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4473 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4474 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4475 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4476 }
4477 }
4478
sourav parmarf4a78252020-04-10 13:04:21 -07004479 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4480 skip |=
4481 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4482 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4483 }
4484 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4485 if (pCreateInfos[i].pLibraryInterface == NULL)
4486 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4487 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4488 }
4489 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4490 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4491 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4492 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4493 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4494 skip |= LogError(
4495 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4496 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4497 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4498 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4499 "must not be VK_SHADER_UNUSED_KHR");
4500 }
4501 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4502 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4503 skip |= LogError(
4504 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4505 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4506 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4507 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4508 "element must not be VK_SHADER_UNUSED_KHR");
4509 }
4510 }
4511 }
4512 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4513 if (pCreateInfos[i].basePipelineIndex != -1) {
4514 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4515 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4516 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4517 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4518 "and pCreateInfos->basePipelineIndex is not -1.");
4519 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004520 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4521 skip |=
4522 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4523 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4524 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4525 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4526 "element.");
4527 }
sourav parmarf4a78252020-04-10 13:04:21 -07004528 }
4529 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4530 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4531 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4532 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4533 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4534 "commands pCreateInfos parameter %d.",
4535 pCreateInfos[i].basePipelineIndex, createInfoCount);
4536 }
4537 } else {
4538 if (pCreateInfos[i].basePipelineIndex != -1) {
4539 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4540 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4541 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4542 }
4543 }
4544 }
4545 if (pCreateInfos[i].libraries.libraryCount == 0) {
4546 if (pCreateInfos[i].stageCount == 0) {
4547 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4548 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4549 }
4550 if (pCreateInfos[i].groupCount == 0) {
4551 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4552 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4553 }
4554 } else {
4555 if (pCreateInfos[i].pLibraryInterface == NULL) {
4556 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4557 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4558 }
4559 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004560 }
4561
4562 return skip;
4563}
4564
Mike Schuchardt21638df2019-03-16 10:52:02 -07004565#ifdef VK_USE_PLATFORM_WIN32_KHR
4566bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4567 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004568 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004569 bool skip = false;
4570 if (!device_extensions.vk_khr_swapchain)
4571 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4572 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4573 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4574 if (!device_extensions.vk_khr_surface)
4575 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4576 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4577 skip |=
4578 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4579 if (!device_extensions.vk_ext_full_screen_exclusive)
4580 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4581 skip |= validate_struct_type(
4582 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4583 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4584 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4585 if (pSurfaceInfo != NULL) {
4586 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4587 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4588 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4589
4590 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4591 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4592 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4593 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004594 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4595 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004596
4597 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4598 }
4599 return skip;
4600}
4601#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004602
4603bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4604 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004605 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004606 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4607 bool skip = false;
4608 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4609 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4610 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4611 }
4612 return skip;
4613}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004614
4615bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004616 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004617 bool skip = false;
4618
4619 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004620 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4621 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004622 }
4623
4624 return skip;
4625}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004626
4627bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004628 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004629 bool skip = false;
4630
4631 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004632 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4633 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004634 }
4635
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004636 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004637 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004638 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4639 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004640 }
4641
4642 return skip;
4643}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004644
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004645bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4646 uint32_t bindingCount, const VkBuffer *pBuffers,
4647 const VkDeviceSize *pOffsets) const {
4648 bool skip = false;
4649 if (firstBinding > device_limits.maxVertexInputBindings) {
4650 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4651 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4652 device_limits.maxVertexInputBindings);
4653 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4654 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4655 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4656 "maxVertexInputBindings (%u)",
4657 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4658 }
4659
Jeff Bolz165818a2020-05-08 11:19:03 -05004660 for (uint32_t i = 0; i < bindingCount; ++i) {
4661 if (pBuffers[i] == VK_NULL_HANDLE) {
4662 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4663 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4664 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4665 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4666 } else {
4667 if (pOffsets[i] != 0) {
4668 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4669 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4670 }
4671 }
4672 }
4673 }
4674
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004675 return skip;
4676}
4677
Mark Lobodzinski84988402019-09-11 15:27:30 -06004678bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004679 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004680 bool skip = false;
4681 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004682 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4683 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004684 }
4685 return skip;
4686}
4687
4688bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004689 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004690 bool skip = false;
4691 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004692 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4693 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004694 }
4695 return skip;
4696}
Petr Kraus3d720392019-11-13 02:52:39 +01004697
4698bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4699 VkSemaphore semaphore, VkFence fence,
4700 uint32_t *pImageIndex) const {
4701 bool skip = false;
4702
4703 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004704 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4705 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004706 }
4707
4708 return skip;
4709}
4710
4711bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4712 uint32_t *pImageIndex) const {
4713 bool skip = false;
4714
4715 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004716 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4717 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004718 }
4719
4720 return skip;
4721}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004722
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004723bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4724 uint32_t firstBinding, uint32_t bindingCount,
4725 const VkBuffer *pBuffers,
4726 const VkDeviceSize *pOffsets,
4727 const VkDeviceSize *pSizes) const {
4728 bool skip = false;
4729
4730 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4731 for (uint32_t i = 0; i < bindingCount; ++i) {
4732 if (pOffsets[i] & 3) {
4733 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4734 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4735 }
4736 }
4737
4738 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4739 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4740 "%s: The firstBinding(%" PRIu32
4741 ") index is greater than or equal to "
4742 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4743 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4744 }
4745
4746 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4747 skip |=
4748 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4749 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4750 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4751 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4752 }
4753
4754 for (uint32_t i = 0; i < bindingCount; ++i) {
4755 // pSizes is optional and may be nullptr.
4756 if (pSizes != nullptr) {
4757 if (pSizes[i] != VK_WHOLE_SIZE &&
4758 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4759 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4760 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4761 ") is not VK_WHOLE_SIZE and is greater than "
4762 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4763 cmd_name, i, pSizes[i]);
4764 }
4765 }
4766 }
4767
4768 return skip;
4769}
4770
4771bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4772 uint32_t firstCounterBuffer,
4773 uint32_t counterBufferCount,
4774 const VkBuffer *pCounterBuffers,
4775 const VkDeviceSize *pCounterBufferOffsets) const {
4776 bool skip = false;
4777
4778 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4779 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4780 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4781 "%s: The firstCounterBuffer(%" PRIu32
4782 ") index is greater than or equal to "
4783 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4784 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4785 }
4786
4787 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4788 skip |=
4789 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4790 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4791 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4792 cmd_name, firstCounterBuffer, counterBufferCount,
4793 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4794 }
4795
4796 return skip;
4797}
4798
4799bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4800 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4801 const VkBuffer *pCounterBuffers,
4802 const VkDeviceSize *pCounterBufferOffsets) const {
4803 bool skip = false;
4804
4805 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4806 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4807 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4808 "%s: The firstCounterBuffer(%" PRIu32
4809 ") index is greater than or equal to "
4810 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4811 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4812 }
4813
4814 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4815 skip |=
4816 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4817 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4818 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4819 cmd_name, firstCounterBuffer, counterBufferCount,
4820 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4821 }
4822
4823 return skip;
4824}
4825
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004826bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4827 uint32_t firstInstance, VkBuffer counterBuffer,
4828 VkDeviceSize counterBufferOffset,
4829 uint32_t counterOffset, uint32_t vertexStride) const {
4830 bool skip = false;
4831
4832 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004833 skip |= LogError(
4834 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004835 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4836 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4837 }
4838
4839 return skip;
4840}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004841
4842bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4843 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4844 const VkAllocationCallbacks *pAllocator,
4845 VkSamplerYcbcrConversion *pYcbcrConversion,
4846 const char *apiName) const {
4847 bool skip = false;
4848
4849 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004850 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004851 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004852 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4853 "samplerYcbcrConversion must be enabled to call %s.", apiName);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004854 }
4855 return skip;
4856}
4857
4858bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4859 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4860 const VkAllocationCallbacks *pAllocator,
4861 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4862 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4863 "vkCreateSamplerYcbcrConversion");
4864}
4865
4866bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4867 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4868 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4869 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4870 "vkCreateSamplerYcbcrConversionKHR");
4871}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004872
4873bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4874 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4875 bool skip = false;
4876 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4877 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4878
4879 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004880 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4881 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4882 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4883 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4884 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004885 }
4886 return skip;
4887}
sourav parmara96ab1a2020-04-25 16:28:23 -07004888
4889bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4890 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4891 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004892 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4893 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4894 skip |=
4895 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4896 "vkCopyAccelerationStructureToMemoryKHR: the "
4897 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4898 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004899 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4900 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4901 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4902 }
4903 return skip;
4904}
4905
4906bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4907 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4908 bool skip = false;
4909 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4910 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4911 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4912 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4913 }
sourav parmar83c31b12020-05-06 12:30:54 -07004914 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4915 if (pNext_struct) {
4916 skip |= LogError(
4917 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4918 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4919 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4920 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004921 return skip;
4922}
4923
4924bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4925 const char *api_name) const {
4926 bool skip = false;
4927 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4928 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4929 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4930 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4931 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4932 api_name);
4933 }
4934 return skip;
4935}
4936
4937bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4938 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4939 bool skip = false;
4940 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004941 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4942 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4943 skip |= LogError(
4944 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4945 "vkCopyAccelerationStructureKHR(): the "
4946 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4947 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004948 return skip;
4949}
4950
4951bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
4952 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4953 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004954 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4955 if (pNext_struct) {
4956 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
4957 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
4958 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
4959 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004960 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
4961 return skip;
4962}
4963
4964bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004965 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07004966 bool skip = false;
4967 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07004968 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06004969 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06004970 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07004971 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
4972 }
4973 return skip;
4974}
4975
4976bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
4977 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4978 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004979 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
4980 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4981 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4982 skip |=
4983 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
4984 "vkCopyMemoryToAccelerationStructureKHR() :the "
4985 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4986 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004987 return skip;
4988}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004989
sourav parmara96ab1a2020-04-25 16:28:23 -07004990bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
4991 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
4992 bool skip = false;
sourav parmara24fb7b2020-05-26 10:50:04 -07004993 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4994 if (pNext_struct) {
4995 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
4996 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
4997 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
4998 }
sourav parmar83c31b12020-05-06 12:30:54 -07004999 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5000 return skip;
5001}
5002bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5003 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5004 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5005 bool skip = false;
5006 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5007 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5008 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5009 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5010 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5011 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5012 }
5013 return skip;
5014}
5015bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5016 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5017 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5018 bool skip = false;
5019 if (dataSize < accelerationStructureCount * stride) {
5020 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5021 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5022 "accelerationStructureCount (%d) *stride(%zu).",
5023 dataSize, accelerationStructureCount, stride);
5024 }
5025 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5026 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5027 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5028 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5029 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5030 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5031 }
5032 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5033 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5034 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5035 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5036 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5037 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5038 stride);
5039 }
5040 }
5041 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5042 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5043 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5044 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5045 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5046 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5047 stride);
5048 }
5049 }
5050 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5051 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5052 skip |=
5053 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5054 "vkWriteAccelerationStructuresPropertiesKHR: the "
5055 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5056 "feature must be enabled ");
5057 }
5058 return skip;
5059}
5060bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5061 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5062 bool skip = false;
5063 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5064 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5065 skip |= LogError(device,
5066 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5067 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5068 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5069 "must be enabled to call this function.");
5070 }
5071 return skip;
5072}
5073
5074bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5075 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5076 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5077 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5078 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5079 uint32_t width, uint32_t height, uint32_t depth) const {
5080 bool skip = false;
5081 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5082 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5083 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5084 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5085 }
5086 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5087 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5088 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5089 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5090 }
5091 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5092 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5093 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5094 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5095 }
5096 // hitShader
5097 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5098 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5099 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5100 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5101 }
5102 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5103 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5104 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5105 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5106 }
5107 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5108 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5109 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5110 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5111 }
5112
5113 // missShader
5114 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5115 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5116 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5117 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5118 }
5119 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5120 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5121 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5122 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5123 }
5124 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5125 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5126 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5127 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5128 }
5129
5130 // raygenShader
5131 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5132 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5133 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5134 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5135 }
5136 return skip;
5137}
5138
5139bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5140 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5141 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5142 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5143 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5144 VkBuffer buffer, VkDeviceSize offset) const {
5145 bool skip = false;
5146 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5147 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5148 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5149 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5150 "feature must be enabled.");
5151 }
5152 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5153 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5154 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5155 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5156 }
5157 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5158 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5159 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5160 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5161 }
5162 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5163 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5164 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5165 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5166 }
5167 // hitShader
5168 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5169 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5170 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5171 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5172 }
5173 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5174 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5175 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5176 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5177 }
5178 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5179 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5180 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5181 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5182 }
5183
5184 // missShader
5185 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5186 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5187 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5188 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5189 }
5190 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5191 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5192 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5193 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5194 }
5195 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5196 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5197 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5198 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5199 }
5200
5201 // raygenShader
5202 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5203 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5204 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5205 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5206 }
5207 return skip;
5208}
5209bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5210 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5211 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5212 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5213 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5214 uint32_t width, uint32_t height, uint32_t depth) const {
5215 bool skip = false;
5216 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5217 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5218 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5219 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5220 }
5221 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5222 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5223 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5224 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5225 }
5226 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5227 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5228 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5229 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5230 }
5231
5232 // hitShader
5233 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5234 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5235 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5236 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5237 }
5238 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5239 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5240 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5241 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5242 }
5243 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5244 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5245 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5246 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5247 }
5248
5249 // missShader
5250 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5251 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5252 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5253 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5254 }
5255 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5256 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5257 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5258 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5259 }
5260 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5261 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5262 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5263 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5264 }
5265
5266 // raygenShader
5267 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5268 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5269 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
5270 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment .");
5271 }
5272 return skip;
5273}
5274
5275bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5276 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5277 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5278 bool skip = false;
5279 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5280 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5281 skip |= LogError(
5282 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5283 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5284 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5285 }
5286 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5287 if (pNext_struct) {
5288 skip |=
5289 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5290 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5291 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5292 }
5293 return false;
5294}
5295
5296bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5297 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5298 bool skip = false;
5299 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5300 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5301 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5302 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5303 }
5304 return skip;
5305}
5306
5307bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5308 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5309 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5310 bool skip = false;
5311 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5312 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005313 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5314 "vkBuildAccelerationStructureKHR: The "
5315 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5316 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005317 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005318 return skip;
5319}
sourav parmara24fb7b2020-05-26 10:50:04 -07005320bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5321 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5322 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5323 bool skip = false;
5324 for (uint32_t i = 0; i < infoCount; ++i) {
5325 const auto *pNext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5326 if (pNext_struct) {
5327 skip |=
5328 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5329 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5330 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5331 }
5332 }
5333 return skip;
5334}