blob: 0feef31f282770cc317ecc10d9ae0102562e5155 [file] [log] [blame]
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08001/* Copyright (c) 2015-2020 The Khronos Group Inc.
2 * Copyright (c) 2015-2020 Valve Corporation
3 * Copyright (c) 2015-2020 LunarG, Inc.
4 * Copyright (C) 2015-2020 Google Inc.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06005 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Mark Lobodzinski <mark@LunarG.com>
John Zulaufa999d1b2018-11-29 13:38:40 -070019 * Author: John Zulauf <jzulauf@lunarg.com>
Mark Lobodzinskid4950072017-08-01 13:02:20 -060020 */
21
orbea80ddc062019-09-10 10:33:19 -070022#include <cmath>
Shahbaz Youssefi6be11412019-01-10 15:29:30 -050023
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070024#include "chassis.h"
25#include "stateless_validation.h"
Mark Lobodzinskie514d1a2019-03-12 08:47:45 -060026#include "layer_chassis_dispatch.h"
Tobias Hectord942eb92018-10-22 15:18:56 +010027
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
John Zulauf71968502017-10-26 13:51:15 -060030template <typename T>
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -070031inline bool in_inclusive_range(const T &value, const T &min, const T &max) {
John Zulauf71968502017-10-26 13:51:15 -060032 // Using only < for generality and || for early abort
33 return !((value < min) || (max < value));
34}
35
Mark Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
58 if (api_version_nopatch < VK_API_VERSION_1_0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070059 skip |= LogError(instance, kVUIDUndefined,
60 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Tony-LunarG866843d2020-05-13 11:22:42 -060088bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
89 const VkValidationFeaturesEXT *validation_features) const {
90 bool skip = false;
91 bool debug_printf = false;
92 bool gpu_assisted = false;
93 bool reserve_slot = false;
94 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
95 switch (validation_features->pEnabledValidationFeatures[i]) {
96 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
97 gpu_assisted = true;
98 break;
99
100 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
101 debug_printf = true;
102 break;
103
104 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
105 reserve_slot = true;
106 break;
107
108 default:
109 break;
110 }
111 }
112 if (reserve_slot && !gpu_assisted) {
113 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
114 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
115 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
116 }
117 if (gpu_assisted && debug_printf) {
118 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
119 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
120 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
121 }
122
123 return skip;
124}
125
John Zulauf620755c2018-04-16 11:00:43 -0600126template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700127ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
128 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600129 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700130 ExtEnabled state =
131 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600132 return state;
133}
134
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700135bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500136 const VkAllocationCallbacks *pAllocator,
137 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700138 bool skip = false;
139 // Note: From the spec--
140 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
141 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
142 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700143 ? pCreateInfo->pApplicationInfo->apiVersion
144 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700145 skip |= validate_api_version(local_api_version, api_version);
146 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600147 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
148 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
149
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700150 return skip;
151}
152
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700153void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700154 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
155 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700156 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
157 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700158 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700159 this->instance_extensions = instance_data->instance_extensions;
160}
161
162void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700163 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700164 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700165 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
167 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700168
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 // Parmeter validation also uses extension data
170 stateless_validation->device_extensions = this->device_extensions;
171
172 VkPhysicalDeviceProperties device_properties = {};
173 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600174 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700175 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
176
177 if (device_extensions.vk_nv_shading_rate_image) {
178 // Get the needed shading rate image limits
179 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
180 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600181 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700182 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
183 }
184
185 if (device_extensions.vk_nv_mesh_shader) {
186 // Get the needed mesh shader limits
187 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
188 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600189 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700190 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
191 }
192
Jason Macnak5c954952019-07-09 15:46:12 -0700193 if (device_extensions.vk_nv_ray_tracing) {
194 // Get the needed ray tracing limits
195 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
196 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
197 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500198 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
199 }
200
201 if (device_extensions.vk_khr_ray_tracing) {
202 // Get the needed ray tracing limits
203 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
204 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
205 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
206 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700207 }
208
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700209 if (device_extensions.vk_ext_transform_feedback) {
210 // Get the needed transform feedback limits
211 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
212 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
213 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
214 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
215 }
216
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800217 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
218
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 // Save app-enabled features in this device's validation object
220 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200221 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
222 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
223 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
224 if (features2) {
225 tmp_features2_state.features = features2->features;
226 } else if (pCreateInfo->pEnabledFeatures) {
227 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700228 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200229 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700230 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200231 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700232 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200233 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234}
235
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700236bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500237 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600238 bool skip = false;
239
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200240 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
241 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
242 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600243 }
244
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200245 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
246 skip |=
247 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
248 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
249 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
250 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600251 }
252
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200253 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700254 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
255 bool negative_viewport =
256 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200257 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700258 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
259 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
260 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200261 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600262 }
263
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600264 {
265 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
266 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
267 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700268 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
269 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
270 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600271 }
272 }
273
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600274 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
275 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600276 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
277 if (features2) {
278 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700279 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700280 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
281 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 }
283 }
284
Locke77fad1c2019-04-16 13:09:03 -0600285 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
286 if (features2) {
287 if (!instance_extensions.vk_khr_get_physical_device_properties_2) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700288 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
289 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct, "
290 "VK_KHR_get_physical_device_properties2 must be enabled when it creates an instance.");
Locke77fad1c2019-04-16 13:09:03 -0600291 }
292 }
293
Jeff Bolz165818a2020-05-08 11:19:03 -0500294 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
295 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
296 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
297 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
298 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
299 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700300 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
301 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
302 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
303 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
304 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
305 "must also be VK_TRUE.");
306 }
Locke77fad1c2019-04-16 13:09:03 -0600307 auto vertex_attribute_divisor_features =
308 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
309 if (vertex_attribute_divisor_features) {
310 bool extension_found = false;
311 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
312 if (0 == strncmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,
313 VK_MAX_EXTENSION_NAME_SIZE)) {
314 extension_found = true;
315 break;
316 }
317 }
318 if (!extension_found) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700319 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
320 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
321 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600322 }
323 }
324
Tony-LunarG28017bc2020-01-23 14:40:25 -0700325 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
326 if (vulkan_11_features) {
327 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
328 while (current) {
329 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
330 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
331 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
332 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
333 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
334 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700335 skip |= LogError(
336 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700337 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
338 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
339 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
340 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
341 break;
342 }
343 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
344 }
345 }
346
347 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
348 if (vulkan_12_features) {
349 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
350 while (current) {
351 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
352 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
353 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
354 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
355 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
361 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
362 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
363 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700364 skip |= LogError(
365 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700366 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
367 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
368 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
369 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
370 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
371 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
372 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
373 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
374 break;
375 }
376 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
377 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700378 // Check features are enabled if matching extension is passed in as well
379 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
380 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
381 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
382 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
383 skip |= LogError(
384 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
385 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
386 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
387 }
388 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
389 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
390 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
391 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
392 "is not VK_TRUE.",
393 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
394 }
395 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
396 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
397 skip |= LogError(
398 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
399 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
400 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
401 }
402 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
403 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
404 skip |= LogError(
405 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
406 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
407 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
408 }
409 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
410 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
411 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
412 skip |=
413 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
414 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
415 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
416 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
417 }
418 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700419 }
420
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600421 // Validate pCreateInfo->pQueueCreateInfos
422 if (pCreateInfo->pQueueCreateInfos) {
423 std::unordered_set<uint32_t> set;
424
425 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700426 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
427 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600428 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700429 skip |=
430 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
431 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
432 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
433 "index value.",
434 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600435 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700436 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
437 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
438 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
439 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600440 } else {
441 set.insert(requested_queue_family);
442 }
443
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700444 if (queue_create_info.pQueuePriorities != nullptr) {
445 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
446 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700448 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
449 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
450 "] (=%f) is not between 0 and 1 (inclusive).",
451 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600452 }
453 }
454 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700455
456 // Need to know if protectedMemory feature is passed in preCall to creating the device
457 VkBool32 protectedMemory = VK_FALSE;
458 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
459 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
460 if (protected_features) {
461 protectedMemory = protected_features->protectedMemory;
462 } else if (vulkan_11_features) {
463 protectedMemory = vulkan_11_features->protectedMemory;
464 }
465 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
466 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
467 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
468 "protectedMemory feature being set as well.");
469 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600470 }
471 }
472
sfricke-samsung30a57412020-05-15 21:14:54 -0700473 // feature dependencies for VK_KHR_variable_pointers
474 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
475 VkBool32 variablePointers = VK_FALSE;
476 VkBool32 variablePointersStorageBuffer = VK_FALSE;
477 if (vulkan_11_features) {
478 variablePointers = vulkan_11_features->variablePointers;
479 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
480 } else if (variable_pointers_features) {
481 variablePointers = variable_pointers_features->variablePointers;
482 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
483 }
484 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
485 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
486 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
487 }
488
sfricke-samsungfd76c342020-05-29 23:13:43 -0700489 // feature dependencies for VK_KHR_multiview
490 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
491 VkBool32 multiview = VK_FALSE;
492 VkBool32 multiviewGeometryShader = VK_FALSE;
493 VkBool32 multiviewTessellationShader = VK_FALSE;
494 if (vulkan_11_features) {
495 multiview = vulkan_11_features->multiview;
496 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
497 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
498 } else if (multiview_features) {
499 multiview = multiview_features->multiview;
500 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
501 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
502 }
503 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
504 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
505 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
506 }
507 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
508 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
509 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
510 }
511
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600512 return skip;
513}
514
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500515bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700516 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700517 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
518 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
519 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600520 }
521
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700522 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600523}
524
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700525bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500526 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100527 bool skip = false;
528
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600529 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700530 skip |=
531 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600532
533 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
534 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
535 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
536 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700537 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
538 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
539 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600540 }
541
542 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
543 // queueFamilyIndexCount uint32_t values
544 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700545 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
546 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
547 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
548 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549 }
550 }
551
552 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
553 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
554 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
555 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700556 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
557 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
558 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600559 }
560 }
561
562 return skip;
563}
564
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700565bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500566 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600567 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600568
569 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600570 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
571 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
572 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
573 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700574 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
575 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
576 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600577 }
578
579 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
580 // queueFamilyIndexCount uint32_t values
581 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700582 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
583 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
584 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
585 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600586 }
587 }
588
Dave Houlton413a6782018-05-22 13:01:54 -0600589 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700590 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600591 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700592 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600593 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700594 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600595
Dave Houlton413a6782018-05-22 13:01:54 -0600596 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700597 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600598 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700599 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600600
Dave Houlton130c0212018-01-29 13:39:56 -0700601 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700602 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
603 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700604 skip |= LogError(
605 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600606 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
607 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700608 }
609
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600610 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100611 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
612 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700613 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
614 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
615 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 }
617
618 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100619 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
620 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700621 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
622 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
623 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
624 ") are not equal.",
625 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100626 }
627
628 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700629 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
630 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
631 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
632 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100633 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600634 }
635
636 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700637 skip |= LogError(
638 device, "VUID-VkImageCreateInfo-imageType-00957",
639 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600640 }
641 }
642
Dave Houlton130c0212018-01-29 13:39:56 -0700643 // 3D image may have only 1 layer
644 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
646 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700647 }
648
649 // If multi-sample, validate type, usage, tiling and mip levels.
650 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
651 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600652 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700653 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
654 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700655 }
656
657 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
658 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
659 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
660 // At least one of the legal attachment bits must be set
661 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700662 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
663 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700664 }
665 // No flags other than the legal attachment bits may be set
666 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
667 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700668 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
669 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700670 }
671 }
672
Jeff Bolzef40fec2018-09-01 22:04:34 -0500673 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600674 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500675 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600676 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
677 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500678 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600679 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700680 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
681 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
682 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600683 }
684
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600685 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700686 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
687 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
688 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600689 }
690
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700691 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700692 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
693 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
694 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100695 }
696
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600697 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
698 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
699 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
700 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700701 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
702 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
703 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600704 }
705
706 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
707 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
708 // Linear tiling is unsupported
709 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700710 skip |= LogError(device, kVUID_PVError_InvalidUsage,
711 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
712 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600713 }
714
715 // Sparse 1D image isn't valid
716 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700717 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
718 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600719 }
720
721 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700722 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700723 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
724 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
725 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600726 }
727
728 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700729 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700730 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
731 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
732 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600733 }
734
735 // Multi-sample 2D image when device doesn't support it
736 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700737 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600738 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700739 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
740 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
741 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700742 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600743 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700744 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
745 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
746 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700747 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600748 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700749 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
750 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
751 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700752 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600753 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
755 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
756 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600757 }
758 }
759 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500760
Jeff Bolz9af91c52018-09-01 21:53:57 -0500761 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
762 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700763 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
764 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
765 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500766 }
767 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700768 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
769 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
770 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500771 }
772 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700773 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
774 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
775 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500776 }
777 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500778
779 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600780 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700781 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
782 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
783 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500784 }
785
Dave Houlton142c4cb2018-10-17 15:04:41 -0600786 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700787 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
788 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
789 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
790 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500791 }
792
Dave Houlton142c4cb2018-10-17 15:04:41 -0600793 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700794 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
795 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
796 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
797 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500798 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600799 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700800 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
801 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
802 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
803 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500804 }
805 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500806
sfricke-samsung8f658d42020-05-03 20:12:24 -0700807 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
808 (FormatHasDepth(pCreateInfo->format) == false)) {
809 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
810 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
811 "format must be a depth or depth/stencil format.");
812 }
813
Andrew Fobel3abeb992020-01-20 16:33:22 -0500814 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
815 if (image_stencil_struct != nullptr) {
816 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
817 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
818 // No flags other than the legal attachment bits may be set
819 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
820 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
822 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
823 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
824 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500825 }
826 }
827
828 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
829 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
830 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
831 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700832 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
833 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
834 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
835 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500836 }
837
838 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
839 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 LogError(device, "VUID-VkImageCreateInfo-format-02537",
841 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
842 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
843 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500844 }
845 }
846
847 if (!physical_device_features.shaderStorageImageMultisample &&
848 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
849 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
850 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700851 LogError(device, "VUID-VkImageCreateInfo-format-02538",
852 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
853 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
854 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500855 }
856
857 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
858 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700859 skip |= LogError(
860 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500861 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
862 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
863 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
864 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
865 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700866 skip |= LogError(
867 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500868 "vkCreateImage(): Depth-stencil image in which usage does not include "
869 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
870 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
871 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
872 }
873
874 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
875 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700876 skip |= LogError(
877 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500878 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
879 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
880 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
881 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
882 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700883 skip |= LogError(
884 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500885 "vkCreateImage(): Depth-stencil image in which usage does not include "
886 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
887 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
888 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
889 }
890 }
891 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700892
893 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
894 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
895 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
896 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
897 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
898 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700899
900 if (device_extensions.vk_ext_image_drm_format_modifier) {
901 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
902 const auto drm_format_mod_explict =
903 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
904 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
905 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
906 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
907 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
908 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
909 "either VkImageDrmFormatModifierListCreateInfoEXT or "
910 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
911 }
912 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
913 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
914 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
915 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
916 "in the pNext chain");
917 }
918 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200919
920 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
921 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
922 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
923 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
924 "imageType must be VK_IMAGE_TYPE_2D.");
925 }
926 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
927 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
928 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
929 "samples must be VK_SAMPLE_COUNT_1_BIT.");
930 }
931 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
932 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
933 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
934 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
935 }
936 }
937 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
938 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
939 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
940 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
941 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
942 }
943 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
944 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
945 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
946 "imageType must be VK_IMAGE_TYPE_2D.");
947 }
948 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
949 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
950 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
951 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
952 }
953 if (pCreateInfo->mipLevels != 1) {
954 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
955 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
956 pCreateInfo->mipLevels);
957 }
958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600959 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500960
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600961 return skip;
962}
963
Jeff Bolz99e3f632020-03-24 22:59:22 -0500964bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
965 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
966 bool skip = false;
967
968 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700969 // Validate feature set if using CUBE_ARRAY
970 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
971 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
972 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
973 "enabling the imageCubeArray feature.");
974 }
975
Jeff Bolz99e3f632020-03-24 22:59:22 -0500976 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
977 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
978 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -0700979 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -0500980 pCreateInfo->subresourceRange.layerCount);
981 }
982 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -0700983 skip |= LogError(
984 device, "VUID-VkImageViewCreateInfo-viewType-02961",
985 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
986 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -0500987 }
988 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -0700989
990 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
991 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
992 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
993 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
994 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
995 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
996 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
997 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
998 }
999 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1000 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1001 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1002 "not an ASTC format.",
1003 string_VkFormat(pCreateInfo->format));
1004 }
1005 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001006 }
1007 return skip;
1008}
1009
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001010bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001011 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001012 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001013
1014 // Note: for numerical correctness
1015 // - float comparisons should expect NaN (comparison always false).
1016 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1017
1018 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001019 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001020 if (v1_f <= 0.0f) return true;
1021
1022 float intpart;
1023 const float fract = modff(v1_f, &intpart);
1024
1025 assert(std::numeric_limits<float>::radix == 2);
1026 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1027 if (intpart >= u32_max_plus1) return false;
1028
1029 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1030 if (v1_u32 < v2_u32)
1031 return true;
1032 else if (v1_u32 == v2_u32 && fract == 0.0f)
1033 return true;
1034 else
1035 return false;
1036 };
1037
1038 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1039 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1040 return (v1_f <= v2_f);
1041 };
1042
1043 // width
1044 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001045 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001046
1047 if (!(viewport.width > 0.0f)) {
1048 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001049 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1050 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001051 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1052 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001053 skip |= LogError(object, "VUID-VkViewport-width-01771",
1054 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1055 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001056 } 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 -07001057 skip |= LogWarning(object, kVUID_PVError_NONE,
1058 "%s: %s.width (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32
1059 "), but it is within the static_cast<float>(maxViewportDimensions[0]) limit.",
1060 fn_name, parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001061 }
1062
1063 // height
1064 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001065 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001066 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001067
1068 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1069 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001070 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1071 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001072 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1073 height_healthy = false;
1074
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001075 skip |= LogError(object, "VUID-VkViewport-height-01773",
1076 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1077 ").",
1078 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001079 } else if (!f_lte_u32_exact(fabsf(viewport.height), max_h) && f_lte_u32_direct(fabsf(viewport.height), max_h)) {
1080 height_healthy = false;
1081
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001082 skip |= LogWarning(
1083 object, kVUID_PVError_NONE,
Petr Krausb3fcdb42018-01-09 22:09:09 +01001084 "%s: Absolute value of %s.height (=%f) technically exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001085 "), but it is within the static_cast<float>(maxViewportDimensions[1]) limit.",
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001086 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001087 }
1088
1089 // x
1090 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001091 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001092 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001093 skip |= LogError(object, "VUID-VkViewport-x-01774",
1094 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1095 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001096 }
1097
1098 // x + width
1099 if (x_healthy && width_healthy) {
1100 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001101 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001102 skip |= LogError(
1103 object, "VUID-VkViewport-x-01232",
1104 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1105 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1106 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001107 }
1108 }
1109
1110 // y
1111 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001112 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001113 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001114 skip |= LogError(object, "VUID-VkViewport-y-01775",
1115 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1116 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001117 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001118 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001119 skip |= LogError(object, "VUID-VkViewport-y-01776",
1120 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1121 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001122 }
1123
1124 // y + height
1125 if (y_healthy && height_healthy) {
1126 const float boundary = viewport.y + viewport.height;
1127
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001128 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001129 skip |= LogError(object, "VUID-VkViewport-y-01233",
1130 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1131 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1132 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001133 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001134 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001135 LogError(object, "VUID-VkViewport-y-01777",
1136 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1137 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1138 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001139 }
1140 }
1141
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001142 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001143 // minDepth
1144 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001145 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001146
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001147 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1148 "[0.0, 1.0] range.",
1149 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001150 }
1151
1152 // maxDepth
1153 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001154 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001155
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001156 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1157 "[0.0, 1.0] range.",
1158 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001159 }
1160 }
1161
1162 return skip;
1163}
1164
Dave Houlton142c4cb2018-10-17 15:04:41 -06001165struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001166 VkShadingRatePaletteEntryNV shadingRate;
1167 uint32_t width;
1168 uint32_t height;
1169};
1170
1171// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001172static SampleOrderInfo sampleOrderInfos[] = {
1173 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1174 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1175 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1176 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1177 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1178 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001179};
1180
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001181bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001182 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001183
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001184 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001185 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001186 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001187 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001188 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001189 break;
1190 }
1191 }
1192
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001193 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001194 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1195 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1196 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001197 return skip;
1198 }
1199
Dave Houlton142c4cb2018-10-17 15:04:41 -06001200 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001201 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001202 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1203 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1204 ") must "
1205 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1206 "is set in framebufferNoAttachmentsSampleCounts.",
1207 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001208 }
1209
Jeff Bolz9af91c52018-09-01 21:53:57 -05001210 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001211 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1212 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1213 ") must "
1214 "be equal to the product of sampleCount (=%" PRIu32
1215 "), the fragment width for shadingRate "
1216 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1217 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001218 }
1219
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001220 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001221 skip |= LogError(
1222 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001223 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1224 ") must "
1225 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001226 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001227 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001228
1229 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001230 // the first width*height*sampleCount bits to all be set. Note: There is no
1231 // guarantee that 64 bits is enough, but practically it's unlikely for an
1232 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001233 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001234 uint64_t sampleLocationsMask = 0;
1235 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1236 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1237 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001238 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1239 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001240 }
1241 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001242 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1243 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001244 }
1245 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001246 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1247 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001248 }
1249 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1250 sampleLocationsMask |= 1ULL << idx;
1251 }
1252
1253 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1254 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001255 skip |= LogError(
1256 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001257 "The array pSampleLocations must contain exactly one entry for "
1258 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001259 }
1260
1261 return skip;
1262}
1263
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001264bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1265 uint32_t createInfoCount,
1266 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1267 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001268 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001269 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001270
1271 if (pCreateInfos != nullptr) {
1272 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001273 bool has_dynamic_viewport = false;
1274 bool has_dynamic_scissor = false;
1275 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001276 bool has_dynamic_depth_bias = false;
1277 bool has_dynamic_blend_constant = false;
1278 bool has_dynamic_depth_bounds = false;
1279 bool has_dynamic_stencil_compare = false;
1280 bool has_dynamic_stencil_write = false;
1281 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001282 bool has_dynamic_viewport_w_scaling_nv = false;
1283 bool has_dynamic_discard_rectangle_ext = false;
1284 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001285 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001286 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001287 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001288 bool has_dynamic_line_stipple = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001289 if (pCreateInfos[i].pDynamicState != nullptr) {
1290 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1291 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1292 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001293 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1294 if (has_dynamic_viewport == true) {
1295 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1296 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1297 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1298 i);
1299 }
1300 has_dynamic_viewport = true;
1301 }
1302 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1303 if (has_dynamic_scissor == true) {
1304 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1305 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1306 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1307 i);
1308 }
1309 has_dynamic_scissor = true;
1310 }
1311 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1312 if (has_dynamic_line_width == true) {
1313 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1314 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1315 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1316 i);
1317 }
1318 has_dynamic_line_width = true;
1319 }
1320 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1321 if (has_dynamic_depth_bias == true) {
1322 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1323 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1324 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1325 i);
1326 }
1327 has_dynamic_depth_bias = true;
1328 }
1329 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1330 if (has_dynamic_blend_constant == true) {
1331 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1332 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1333 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1334 i);
1335 }
1336 has_dynamic_blend_constant = true;
1337 }
1338 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1339 if (has_dynamic_depth_bounds == true) {
1340 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1341 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1342 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1343 i);
1344 }
1345 has_dynamic_depth_bounds = true;
1346 }
1347 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1348 if (has_dynamic_stencil_compare == true) {
1349 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1350 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1351 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1352 i);
1353 }
1354 has_dynamic_stencil_compare = true;
1355 }
1356 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1357 if (has_dynamic_stencil_write == true) {
1358 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1359 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1360 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1361 i);
1362 }
1363 has_dynamic_stencil_write = true;
1364 }
1365 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1366 if (has_dynamic_stencil_reference == true) {
1367 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1368 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1369 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1370 i);
1371 }
1372 has_dynamic_stencil_reference = true;
1373 }
1374 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1375 if (has_dynamic_viewport_w_scaling_nv == true) {
1376 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1377 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1378 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1379 i);
1380 }
1381 has_dynamic_viewport_w_scaling_nv = true;
1382 }
1383 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1384 if (has_dynamic_discard_rectangle_ext == true) {
1385 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1386 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1387 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1388 i);
1389 }
1390 has_dynamic_discard_rectangle_ext = true;
1391 }
1392 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1393 if (has_dynamic_sample_locations_ext == true) {
1394 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1395 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1396 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1397 i);
1398 }
1399 has_dynamic_sample_locations_ext = true;
1400 }
1401 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1402 if (has_dynamic_exclusive_scissor_nv == true) {
1403 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1404 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1405 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1406 i);
1407 }
1408 has_dynamic_exclusive_scissor_nv = true;
1409 }
1410 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1411 if (has_dynamic_shading_rate_palette_nv == true) {
1412 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1413 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1414 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1415 i);
1416 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001417 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001418 }
1419 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1420 if (has_dynamic_viewport_course_sample_order_nv == true) {
1421 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1422 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1423 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1424 i);
1425 }
1426 has_dynamic_viewport_course_sample_order_nv = true;
1427 }
1428 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1429 if (has_dynamic_line_stipple == true) {
1430 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1431 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1432 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1433 i);
1434 }
1435 has_dynamic_line_stipple = true;
1436 }
Petr Kraus299ba622017-11-24 03:09:03 +01001437 }
1438 }
1439
Peter Chen85366392019-05-14 15:20:11 -04001440 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1441 if ((feedback_struct != nullptr) &&
1442 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001443 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1444 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1445 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1446 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1447 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001448 }
1449
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001450 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001451
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001452 // Collect active stages and other information
1453 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001454 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001455 bool has_eval = false;
1456 bool has_control = false;
1457 if (pCreateInfos[i].pStages != nullptr) {
1458 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1459 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1460
1461 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1462 has_control = true;
1463 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1464 has_eval = true;
1465 }
1466
1467 skip |= validate_string(
1468 "vkCreateGraphicsPipelines",
1469 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1470 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1471 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001472 }
1473
1474 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1475 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1476 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1477 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1478 pCreateInfos[i].pTessellationState,
1479 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1480 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1481
1482 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1483 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1484
1485 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1486 "VkPipelineTessellationDomainOriginStateCreateInfo",
1487 pCreateInfos[i].pTessellationState->pNext,
1488 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1489 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001490 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1491 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001492
1493 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1494 pCreateInfos[i].pTessellationState->flags,
1495 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1496 }
1497
1498 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1499 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1500 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1501 pCreateInfos[i].pInputAssemblyState,
1502 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1503 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1504
1505 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1506 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001507 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001508
1509 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1510 pCreateInfos[i].pInputAssemblyState->flags,
1511 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1512
1513 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1514 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1515 pCreateInfos[i].pInputAssemblyState->topology,
1516 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1517
1518 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1519 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1520 }
1521
1522 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001523 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001524
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001525 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001526 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1527 "vkCreateGraphicsPipelines: pararameter "
1528 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1529 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001530 }
1531
1532 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1533 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1534 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1535 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1536 pCreateInfos[i].pVertexInputState->pNext, 1,
1537 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001538 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1539 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001540 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1541 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001542 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001543 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1544 skip |=
1545 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1546 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1547 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1548 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1549 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1550
1551 skip |= validate_array(
1552 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1553 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1554 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1555 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1556
1557 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1558 for (uint32_t vertexBindingDescriptionIndex = 0;
1559 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1560 ++vertexBindingDescriptionIndex) {
1561 skip |= validate_ranged_enum(
1562 "vkCreateGraphicsPipelines",
1563 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1564 AllVkVertexInputRateEnums,
1565 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1566 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1567 }
1568 }
1569
1570 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1571 for (uint32_t vertexAttributeDescriptionIndex = 0;
1572 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1573 ++vertexAttributeDescriptionIndex) {
1574 skip |= validate_ranged_enum(
1575 "vkCreateGraphicsPipelines",
1576 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1577 AllVkFormatEnums,
1578 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1579 "VUID-VkVertexInputAttributeDescription-format-parameter");
1580 }
1581 }
1582
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001583 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001584 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1585 "vkCreateGraphicsPipelines: pararameter "
1586 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1587 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1588 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001589 }
1590
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001591 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001592 skip |=
1593 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1594 "vkCreateGraphicsPipelines: pararameter "
1595 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1596 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1597 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001598 }
1599
1600 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001601 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1602 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001603 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1604 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001605 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1606 "vkCreateGraphicsPipelines: parameter "
1607 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1608 "(%" PRIu32 ") is not distinct.",
1609 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001610 }
1611 vertex_bindings.insert(vertex_bind_desc.binding);
1612
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001613 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001614 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1615 "vkCreateGraphicsPipelines: parameter "
1616 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1617 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1618 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001619 }
1620
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001621 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001622 skip |=
1623 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1624 "vkCreateGraphicsPipelines: parameter "
1625 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1626 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1627 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001628 }
1629 }
1630
Peter Kohautc7d9d392018-07-15 00:34:07 +02001631 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001632 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1633 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001634 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1635 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001636 skip |= LogError(
1637 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001638 "vkCreateGraphicsPipelines: parameter "
1639 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1640 i, d, vertex_attrib_desc.location);
1641 }
1642 attribute_locations.insert(vertex_attrib_desc.location);
1643
1644 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1645 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001646 skip |= LogError(
1647 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001648 "vkCreateGraphicsPipelines: parameter "
1649 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1650 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1651 i, d, vertex_attrib_desc.binding, i);
1652 }
1653
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001654 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001655 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1656 "vkCreateGraphicsPipelines: parameter "
1657 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1658 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1659 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001660 }
1661
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001662 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001663 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1664 "vkCreateGraphicsPipelines: parameter "
1665 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1666 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1667 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001668 }
1669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001670 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001671 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1672 "vkCreateGraphicsPipelines: parameter "
1673 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1674 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1675 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001676 }
1677 }
1678 }
1679
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001680 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1681 if (has_control && has_eval) {
1682 if (pCreateInfos[i].pTessellationState == nullptr) {
1683 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1684 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1685 "shader stage and a tessellation evaluation shader stage, "
1686 "pCreateInfos[%d].pTessellationState must not be NULL.",
1687 i, i);
1688 } else {
1689 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1690 skip |= validate_struct_pnext(
1691 "vkCreateGraphicsPipelines",
1692 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1693 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1694 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1695 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001696
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001697 skip |= validate_reserved_flags(
1698 "vkCreateGraphicsPipelines",
1699 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1700 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001701
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001702 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1703 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1704 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1705 "vkCreateGraphicsPipelines: invalid parameter "
1706 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1707 "should be >0 and <=%u.",
1708 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1709 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001710 }
1711 }
1712 }
1713
1714 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1715 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1716 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1717 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001718 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1719 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1720 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1721 "].pViewportState (=NULL) is not a valid pointer.",
1722 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001723 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001724 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1725
1726 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001727 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1728 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1729 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1730 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001731 }
1732
Petr Krausa6103552017-11-16 21:21:58 +01001733 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1734 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001735 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1736 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001737 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1738 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001739 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001740 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001741 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001742 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001743 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001744 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1745 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001746 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001747 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1748 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001749
1750 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001751 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001752 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001753 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001754
Dave Houlton142c4cb2018-10-17 15:04:41 -06001755 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1756 pCreateInfos[i].pViewportState->pNext);
1757 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1758 pCreateInfos[i].pViewportState->pNext);
1759 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1760 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001761 const auto vp_swizzle_struct =
1762 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001763 const auto vp_w_scaling_struct =
1764 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001765
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001766 if (!physical_device_features.multiViewport) {
Petr Krausa6103552017-11-16 21:21:58 +01001767 if (viewport_state.viewportCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001768 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1769 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1770 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1771 ") is not 1.",
1772 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001773 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001774
Petr Krausa6103552017-11-16 21:21:58 +01001775 if (viewport_state.scissorCount != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001776 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1777 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1778 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
1779 ") is not 1.",
1780 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001781 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001782
Dave Houlton142c4cb2018-10-17 15:04:41 -06001783 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
1784 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001785 skip |= LogError(
1786 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
1787 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1788 "disabled, but pCreateInfos[%" PRIu32
1789 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
1790 ") is not 1.",
1791 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001792 }
1793
Jeff Bolz9af91c52018-09-01 21:53:57 -05001794 if (shading_rate_image_struct &&
1795 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001796 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
1797 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1798 "disabled, but pCreateInfos[%" PRIu32
1799 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
1800 ") is neither 0 nor 1.",
1801 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001802 }
1803
Petr Krausa6103552017-11-16 21:21:58 +01001804 } else { // multiViewport enabled
1805 if (viewport_state.viewportCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001806 skip |= LogError(
1807 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001808 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001809 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001810 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
1811 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1812 "].pViewportState->viewportCount (=%" PRIu32
1813 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1814 i, viewport_state.viewportCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001815 }
Petr Krausa6103552017-11-16 21:21:58 +01001816
1817 if (viewport_state.scissorCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001818 skip |= LogError(
1819 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001820 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001821 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001822 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
1823 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1824 "].pViewportState->scissorCount (=%" PRIu32
1825 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1826 i, viewport_state.scissorCount, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001827 }
1828 }
1829
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001830 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001831 skip |=
1832 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
1833 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1834 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1835 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001836 }
1837
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001838 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001839 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
1840 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1841 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1842 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
1843 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001844 }
1845
Petr Krausa6103552017-11-16 21:21:58 +01001846 if (viewport_state.scissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001847 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
1848 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1849 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
1850 "].pViewportState->viewportCount (=%" PRIu32 ").",
1851 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001852 }
1853
Dave Houlton142c4cb2018-10-17 15:04:41 -06001854 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05001855 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001856 skip |=
1857 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
1858 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
1859 ") must be zero or identical to pCreateInfos[%" PRIu32
1860 "].pViewportState->viewportCount (=%" PRIu32 ").",
1861 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001862 }
1863
Dave Houlton142c4cb2018-10-17 15:04:41 -06001864 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05001865 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001866 skip |= LogError(
1867 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001868 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
1869 "] "
1870 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
1871 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
1872 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001873 }
1874
Petr Krausa6103552017-11-16 21:21:58 +01001875 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001876 skip |= LogError(
1877 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01001878 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
1879 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001880 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
1881 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001882 }
1883
1884 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001885 skip |= LogError(
1886 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01001887 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
1888 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06001889 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
1890 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01001891 }
1892
Jeff Bolz3e71f782018-08-29 23:15:45 -05001893 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001894 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
1895 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
1896 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06001897 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001898 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
1899 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
1900 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
1901 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001902 }
1903
Jeff Bolz9af91c52018-09-01 21:53:57 -05001904 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06001905 shading_rate_image_struct->viewportCount > 0 &&
1906 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001907 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06001908 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001909 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06001910 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
1911 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05001912 i, i);
1913 }
1914
Chris Mayer328d8212018-12-11 14:16:18 +01001915 if (vp_swizzle_struct) {
1916 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001917 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
1918 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
1919 " does "
1920 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
1921 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01001922 }
1923 }
1924
Petr Krausb3fcdb42018-01-09 22:09:09 +01001925 // validate the VkViewports
1926 if (!has_dynamic_viewport && viewport_state.pViewports) {
1927 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
1928 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001929 const char *fn_name = "vkCreateGraphicsPipelines";
1930 skip |= manual_PreCallValidateViewport(viewport, fn_name,
1931 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
1932 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001933 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01001934 }
1935 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001936
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001937 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001938 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1939 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1940 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
1941 "VK_NV_clip_space_w_scaling extension is not enabled.",
1942 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001943 }
1944
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001945 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001946 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1947 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1948 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
1949 "VK_EXT_discard_rectangles extension is not enabled.",
1950 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001951 }
1952
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001953 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001954 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1955 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1956 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
1957 "VK_EXT_sample_locations extension is not enabled.",
1958 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001959 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05001960
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001961 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001962 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
1963 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1964 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
1965 "VK_NV_scissor_exclusive extension is not enabled.",
1966 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001967 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001968
1969 if (coarse_sample_order_struct &&
1970 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
1971 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001972 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
1973 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1974 "] "
1975 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
1976 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
1977 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001978 }
1979
1980 if (coarse_sample_order_struct) {
1981 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001982 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001983 }
1984 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001985
1986 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
1987 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001988 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
1989 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1990 "] "
1991 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
1992 ") "
1993 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
1994 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001995 }
1996 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001997 skip |= LogError(
1998 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001999 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2000 "] "
2001 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2002 i);
2003 }
2004 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002005 }
2006
2007 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002008 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2009 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2010 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2011 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002012 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002013 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
2014 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2015 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002016 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002017 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002018 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002019 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002020 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002021 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002022 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 3, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002023 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2024 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002025
2026 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002027 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002028 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002029 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002030
2031 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002032 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002033 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2034 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2035
2036 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002037 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002038 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2039 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002040 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002041 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002042
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002043 skip |= validate_flags(
2044 "vkCreateGraphicsPipelines",
2045 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2046 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002047 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002048
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002049 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002050 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002051 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2052 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2053
2054 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002055 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002056 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2057 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2058
2059 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002060 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2061 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2062 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2063 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002064 }
John Zulauf7acac592017-11-06 11:15:53 -07002065 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002066 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002067 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2068 "vkCreateGraphicsPipelines(): parameter "
2069 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2070 i);
John Zulauf7acac592017-11-06 11:15:53 -07002071 }
2072 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2073 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2074 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002075 skip |= LogError(
2076 device,
2077
Dave Houlton413a6782018-05-22 13:01:54 -06002078 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002079 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002080 }
2081 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002082
2083 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2084 pCreateInfos[i].pRasterizationState->pNext);
2085
2086 if (line_state) {
2087 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2088 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2089 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2090 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002091 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2092 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2093 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2094 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002095 }
2096 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2097 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002098 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2099 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2100 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2101 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002102 }
2103 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2104 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002105 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2106 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2107 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2108 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002109 }
2110 }
2111 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2112 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2113 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002114 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2115 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2116 "range [1,256].",
2117 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002118 }
2119 }
2120 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002121 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002122 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2123 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002124 skip |=
2125 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2126 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2127 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2128 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002129 }
2130 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2131 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002132 skip |=
2133 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2134 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2135 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2136 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002137 }
2138 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2139 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002140 skip |=
2141 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2142 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2143 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2144 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002145 }
2146 if (line_state->stippledLineEnable) {
2147 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2148 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002149 skip |=
2150 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2151 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2152 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2153 "stippledRectangularLines feature.",
2154 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002155 }
2156 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2157 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002158 skip |=
2159 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2160 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2161 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2162 "stippledBresenhamLines feature.",
2163 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002164 }
2165 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2166 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002167 skip |=
2168 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2169 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2170 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2171 "stippledSmoothLines feature.",
2172 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002173 }
2174 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2175 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002176 skip |=
2177 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2178 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2179 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2180 "stippledRectangularLines and strictLines features.",
2181 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002182 }
2183 }
2184 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002185 }
2186
Petr Krause91f7a12017-12-14 20:57:36 +01002187 bool uses_color_attachment = false;
2188 bool uses_depthstencil_attachment = false;
2189 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002190 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002191 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2192 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002193 const auto &subpasses_uses = subpasses_uses_it->second;
2194 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2195 uses_color_attachment = true;
2196 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2197 uses_depthstencil_attachment = true;
2198 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002199 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002200 }
2201
2202 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002203 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002204 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002205 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002206 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002207 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002208
2209 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002210 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002211 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002212 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002213
2214 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002215 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002216 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2217 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2218
2219 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002220 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002221 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2222 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2223
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->depthCompareOp", ParameterName::IndexVector{i}),
2227 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002228 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002229
2230 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002231 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002232 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2233 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2234
2235 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002236 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002237 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2238 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2239
2240 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002241 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002242 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2243 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002244 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002245
2246 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002247 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002248 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2249 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002250 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251
2252 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002253 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002254 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2255 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002256 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002257
2258 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002259 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002260 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2261 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002262 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002263
2264 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002265 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002266 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2267 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002268 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002269
2270 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002271 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002272 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2273 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002274 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002275
2276 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002277 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002278 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2279 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002280 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002281
2282 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002283 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002284 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2285 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002286 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002287
2288 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002289 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2290 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2291 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2292 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002293 }
2294 }
2295
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002296 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2297 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2298
Petr Krause91f7a12017-12-14 20:57:36 +01002299 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002300 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2301 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2302 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2303 pCreateInfos[i].pColorBlendState,
2304 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2305 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2306
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002307 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002308 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002309 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2310 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2311 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002312 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002313 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2314 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002315
2316 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002317 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002318 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002319 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002320
2321 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002322 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002323 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2324 pCreateInfos[i].pColorBlendState->logicOpEnable);
2325
2326 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002327 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002328 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2329 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002330 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002331 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002332
2333 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2334 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2335 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002336 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002337 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2338 ParameterName::IndexVector{i, attachmentIndex}),
2339 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2340
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].srcColorBlendFactor",
2344 ParameterName::IndexVector{i, attachmentIndex}),
2345 "VkBlendFactor", AllVkBlendFactorEnums,
2346 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002347 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002348
2349 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002350 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002351 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2352 ParameterName::IndexVector{i, attachmentIndex}),
2353 "VkBlendFactor", AllVkBlendFactorEnums,
2354 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002355 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002356
2357 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002358 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002359 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2360 ParameterName::IndexVector{i, attachmentIndex}),
2361 "VkBlendOp", AllVkBlendOpEnums,
2362 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002363 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002364
2365 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002366 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002367 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2368 ParameterName::IndexVector{i, attachmentIndex}),
2369 "VkBlendFactor", AllVkBlendFactorEnums,
2370 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002371 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002372
2373 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002374 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002375 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2376 ParameterName::IndexVector{i, attachmentIndex}),
2377 "VkBlendFactor", AllVkBlendFactorEnums,
2378 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002379 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002380
2381 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002382 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002383 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2384 ParameterName::IndexVector{i, attachmentIndex}),
2385 "VkBlendOp", AllVkBlendOpEnums,
2386 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002387 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002388
2389 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002390 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002391 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2392 ParameterName::IndexVector{i, attachmentIndex}),
2393 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2394 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002395 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002396 }
2397 }
2398
2399 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002400 skip |= LogError(device, kVUID_PVError_InvalidStructSType,
2401 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2402 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2403 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002404 }
2405
2406 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2407 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2408 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002409 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002410 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002411 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2412 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002413 }
2414 }
2415 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002416
Petr Kraus9752aae2017-11-24 03:05:50 +01002417 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2418 if (pCreateInfos[i].basePipelineIndex != -1) {
2419 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002420 skip |=
2421 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002422 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002423 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002424 "and pCreateInfos->basePipelineIndex is not -1.",
2425 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002426 }
2427 }
2428
Petr Kraus9752aae2017-11-24 03:05:50 +01002429 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2430 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002431 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002432 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002433 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002434 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2435 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002436 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002437 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002438 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002439 skip |=
2440 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2441 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2442 "index into the pCreateInfos array, of size %d.",
2443 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002444 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 }
2446 }
2447
sfricke-samsung898cf222020-05-15 23:10:19 -07002448 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2449 skip |= LogError(
2450 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2451 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2452 i);
2453 }
2454
Petr Kraus9752aae2017-11-24 03:05:50 +01002455 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002456 if (!device_extensions.vk_nv_fill_rectangle) {
2457 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2458 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002459 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2460 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2461 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2462 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002463 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2464 (physical_device_features.fillModeNonSolid == false)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002465 skip |= LogError(device, kVUID_PVError_DeviceFeature,
2466 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002467 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2468 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2469 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002470 }
2471 } else {
2472 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2473 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2474 (physical_device_features.fillModeNonSolid == false)) {
2475 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002476 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2477 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002478 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2479 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2480 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002481 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002482 }
Petr Kraus299ba622017-11-24 03:09:03 +01002483
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002484 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002485 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002486 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2487 "The line width state is static (pCreateInfos[%" PRIu32
2488 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2489 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2490 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2491 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002492 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002493 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494 }
2495 }
2496
2497 return skip;
2498}
2499
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002500bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2501 uint32_t createInfoCount,
2502 const VkComputePipelineCreateInfo *pCreateInfos,
2503 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002504 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002505 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002507 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002508 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002509 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002510 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2511 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002512 skip |=
2513 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2514 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2515 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2516 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002517 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002518
2519 // Make sure compute stage is selected
2520 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002521 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2522 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2523 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002524 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002525 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002526 return skip;
2527}
2528
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002529bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002530 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002531 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002532
2533 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002534 const auto &features = physical_device_features;
2535 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002536
John Zulauf71968502017-10-26 13:51:15 -06002537 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2538 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002539 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2540 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2541 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2542 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002543 }
2544
2545 // Anistropy cannot be enabled in sampler unless enabled as a feature
2546 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002547 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2548 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2549 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002550 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002551 }
John Zulauf71968502017-10-26 13:51:15 -06002552
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002553 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2554 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002555 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2556 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2557 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2558 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002559 }
2560 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002561 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2562 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2563 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2564 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002565 }
2566 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002567 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2568 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2569 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2570 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002571 }
2572 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2573 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2574 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2575 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002576 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2577 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2578 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2579 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2580 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2581 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002582 }
2583 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002584 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2585 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2586 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002587 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002588 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002589 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2590 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2591 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002592 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002593 }
2594
2595 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2596 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002597 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2598 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002599 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2600 if (sampler_reduction != nullptr) {
2601 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2602 skip |= LogError(
2603 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2604 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2605 }
2606 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607 }
2608
2609 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2610 // valid VkBorderColor value
2611 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2612 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2613 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002614 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2615 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002616 }
2617
2618 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2619 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002620 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002621 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2622 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2623 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002624 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002625 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2626 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2627 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628 }
John Zulauf275805c2017-10-26 15:34:49 -06002629
2630 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002631 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002632 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2633 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002634 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2635 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2636 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002637 }
2638 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002639
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002640 // Check for valid Lod range
2641 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002642 skip |=
2643 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2644 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002645 }
2646
2647 // Check mipLodBias to device limit
2648 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002649 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2650 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2651 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002652 }
2653
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002654 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2655 if (sampler_conversion != nullptr) {
2656 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2657 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2658 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2659 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002660 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002661 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002662 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2663 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2664 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2665 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2666 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2667 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2668 }
2669 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002670
2671 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2672 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2673 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2674 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2675 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2676 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2677 }
2678 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2679 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2680 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2681 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2682 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2683 }
2684 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2685 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2686 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2687 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2688 pCreateInfo->minLod, pCreateInfo->maxLod);
2689 }
2690 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2691 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2692 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2693 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2694 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2695 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2696 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2697 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2698 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2699 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2700 }
2701 if (pCreateInfo->anisotropyEnable) {
2702 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2703 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2704 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2705 }
2706 if (pCreateInfo->compareEnable) {
2707 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2708 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2709 "pCreateInfo->compareEnable must be VK_FALSE");
2710 }
2711 if (pCreateInfo->unnormalizedCoordinates) {
2712 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2713 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2714 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2715 }
2716 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002717 }
2718
Tony-LunarG7337b312020-04-15 16:40:25 -06002719 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2720 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2721 if (!device_extensions.vk_ext_custom_border_color) {
2722 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2723 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2724 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2725 }
2726 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2727 if (!custom_create_info) {
2728 skip |=
2729 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2730 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2731 "struct in pNext chain.\n",
2732 string_VkBorderColor(pCreateInfo->borderColor));
2733 } else {
2734 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2735 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2736 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2737 !FormatIsSampledFloat(custom_create_info->format)))) {
2738 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2739 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2740 "whose type does not match\n",
2741 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2742 ;
2743 }
2744 }
2745 }
2746
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002747 return skip;
2748}
2749
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002750bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2751 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2752 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002753 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002754 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002755
2756 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2757 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2758 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2759 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002760 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2761 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
2762 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
2763 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
2764 ++descriptor_index) {
2765 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07002766 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002767 "vkCreateDescriptorSetLayout: required parameter "
2768 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
2769 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002770 }
2771 }
2772 }
2773
2774 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
2775 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
2776 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002777 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
2778 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
2779 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
2780 "values.",
2781 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002782 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07002783
2784 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
2785 (pCreateInfo->pBindings[i].stageFlags != 0) &&
2786 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
2787 skip |=
2788 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
2789 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
2790 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
2791 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
2792 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
2793 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002794 }
2795 }
2796 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002797 return skip;
2798}
2799
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002800bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
2801 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002802 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002803 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2804 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2805 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002806 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
2807 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002808}
2809
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002810bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
2811 const VkWriteDescriptorSet *pDescriptorWrites,
2812 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002813 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002814
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002815 if (pDescriptorWrites != NULL) {
2816 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
2817 // descriptorCount must be greater than 0
2818 if (pDescriptorWrites[i].descriptorCount == 0) {
2819 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002820 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
2821 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002822 }
2823
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002824 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
2825 if (validateDstSet) {
2826 // dstSet must be a valid VkDescriptorSet handle
2827 skip |= validate_required_handle(vkCallingFunction,
2828 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
2829 pDescriptorWrites[i].dstSet);
2830 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002831
2832 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
2833 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
2834 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
2835 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
2836 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
2837 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2838 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05002839 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
2840 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002841 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002842 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
2843 "%s(): if pDescriptorWrites[%d].descriptorType is "
2844 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
2845 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
2846 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
2847 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002848 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
2849 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05002850 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
2851 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002852 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
2853 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002854 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002855 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
2856 ParameterName::IndexVector{i, descriptor_index}),
2857 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06002858 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002859 }
2860 }
2861 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2862 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2863 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
2864 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
2865 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
2866 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
2867 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05002868 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002869 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002870 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
2871 "%s(): if pDescriptorWrites[%d].descriptorType is "
2872 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
2873 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
2874 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
2875 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002876 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05002877 const auto *robustness2_features =
2878 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
2879 if (robustness2_features && robustness2_features->nullDescriptor) {
2880 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
2881 ++descriptorIndex) {
2882 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
2883 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
2884 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
2885 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
2886 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
2887 "offset (" PRIu64 ") must be zero and range (" PRIu64 ") must be VK_WHOLE_SIZE.",
2888 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
2889 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
2890 }
2891 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002892 }
2893 }
2894 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
2895 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05002896 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002897 }
2898
2899 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
2900 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002901 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002902 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2903 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2904 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002905 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002906 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
2907 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2908 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2909 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002910 }
2911 }
2912 }
2913 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
2914 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002915 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002916 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
2917 if (pDescriptorWrites[i].pBufferInfo != NULL) {
2918 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06002919 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002920 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
2921 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
2922 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
2923 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002924 }
2925 }
2926 }
2927 }
sourav parmara96ab1a2020-04-25 16:28:23 -07002928 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
2929 // or VkWriteDescriptorSetInlineUniformBlockEX
2930 if (pDescriptorWrites[i].pNext) {
2931 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002932 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07002933 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002934 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002935 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
2936 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
2937 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
2938 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002939 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07002940 pDescriptorWrites[i].descriptorCount);
2941 }
2942 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002943 if (pnext_struct) {
2944 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002945 skip |= LogError(
2946 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
2947 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
2948 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002949 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07002950 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06002951 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07002952 skip |= LogError(
2953 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
2954 "%s(): accelerationStructureCount must be greater than 0 .");
2955 }
2956 }
2957 }
2958 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002959 }
2960 }
2961 return skip;
2962}
2963
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07002964bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
2965 const VkWriteDescriptorSet *pDescriptorWrites,
2966 uint32_t descriptorCopyCount,
2967 const VkCopyDescriptorSet *pDescriptorCopies) const {
2968 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
2969}
2970
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002971bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002972 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002973 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002974 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
2975}
2976
2977bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002978 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002979 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002980 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
2981}
2982
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002983bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
2984 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002985 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002986 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987
2988 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2989 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
2990 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002991 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
2992 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002993 return skip;
2994}
2995
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002996bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002997 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002998 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02002999
3000 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3001 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003002 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3003
Petr Krause7bb9e82019-08-11 21:34:43 +02003004 // Implicit VUs
3005 // validate only sType here; pointer has to be validated in core_validation
3006 const bool kNotRequired = false;
3007 const char *kNoVUID = nullptr;
3008 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3009 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3010 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003011
Petr Krause7bb9e82019-08-11 21:34:43 +02003012 if (pInfo) {
3013 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3014 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3015 skip |= validate_struct_pnext(
3016 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3017 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003018 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3019 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003020
Petr Krause7bb9e82019-08-11 21:34:43 +02003021 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003022
Petr Krause7bb9e82019-08-11 21:34:43 +02003023 // Explicit VUs
3024 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003025 skip |= LogError(
3026 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003027 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3028 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003029 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003030
3031 if (physical_device_features.inheritedQueries) {
3032 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003033 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003034 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003035 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003036 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003037 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003038 }
3039
3040 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003041 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003042 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003043 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003044 } else { // !pipelineStatisticsQuery
3045 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3046 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003047 }
Petr Kraus139757b2019-08-15 17:19:33 +02003048
3049 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3050 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003051 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003052 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3053 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003054 skip |= LogError(
3055 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003056 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3057 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3058 }
3059 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003060 }
3061
3062 return skip;
3063}
3064
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003065bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003066 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003067 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003068
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003069 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003070 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003071 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3072 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3073 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003074 }
3075 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003076 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3077 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3078 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003079 }
3080 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003081 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003082 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003083 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3084 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3085 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3086 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003087 }
3088 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003089
3090 if (pViewports) {
3091 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3092 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003093 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003094 skip |= manual_PreCallValidateViewport(
3095 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003096 }
3097 }
3098
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 return skip;
3100}
3101
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003102bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003103 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003104 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003105
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003106 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003107 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003108 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3109 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3110 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003111 }
3112 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003113 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3114 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3115 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003116 }
3117 } else { // multiViewport enabled
3118 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003119 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003120 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3121 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3122 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3123 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003124 }
3125 }
3126
Petr Kraus6260f0a2018-02-27 21:15:55 +01003127 if (pScissors) {
3128 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3129 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003130
Petr Kraus6260f0a2018-02-27 21:15:55 +01003131 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003132 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3133 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3134 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003135 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003136
Petr Kraus6260f0a2018-02-27 21:15:55 +01003137 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003138 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3139 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3140 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003141 }
3142
3143 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3144 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003145 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3146 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3147 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3148 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003149 }
3150
3151 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3152 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003153 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3154 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3155 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3156 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003157 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003158 }
3159 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003160
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003161 return skip;
3162}
3163
Jeff Bolz5c801d12019-10-09 10:38:45 -05003164bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003165 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003166
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003167 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003168 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3169 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003170 }
3171
3172 return skip;
3173}
3174
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003175bool StatelessValidation::manual_PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003176 uint32_t firstVertex, uint32_t firstInstance) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003177 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003178 if (vertexCount == 0) {
3179 // TODO: Verify against Valid Usage section. I don't see a non-zero vertexCount listed, may need to add that and make
3180 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003181 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t vertexCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003182 }
3183
3184 if (instanceCount == 0) {
3185 // TODO: Verify against Valid Usage section. I don't see a non-zero instanceCount listed, may need to add that and make
3186 // this an error or leave as is.
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003187 skip |= LogWarning(device, kVUID_PVError_RequiredParameter, "vkCmdDraw parameter, uint32_t instanceCount, is 0");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003188 }
3189 return skip;
3190}
3191
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003192bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003193 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003194 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003195
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003196 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003197 skip |= LogError(device, kVUID_PVError_DeviceFeature,
3198 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003199 }
3200 return skip;
3201}
3202
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003203bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003204 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003205 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003206 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003207 skip |=
3208 LogError(device, kVUID_PVError_DeviceFeature,
3209 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003210 }
3211 return skip;
3212}
3213
sfricke-samsungf692b972020-05-02 08:00:45 -07003214bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3215 VkDeviceSize countBufferOffset, bool khr) const {
3216 bool skip = false;
3217 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3218 if (offset & 3) {
3219 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3220 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3221 }
3222
3223 if (countBufferOffset & 3) {
3224 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3225 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3226 countBufferOffset);
3227 }
3228 return skip;
3229}
3230
3231bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3232 VkDeviceSize offset, VkBuffer countBuffer,
3233 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3234 uint32_t stride) const {
3235 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3236}
3237
3238bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3239 VkDeviceSize offset, VkBuffer countBuffer,
3240 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3241 uint32_t stride) const {
3242 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3243}
3244
3245bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3246 VkDeviceSize countBufferOffset, bool khr) const {
3247 bool skip = false;
3248 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3249 if (offset & 3) {
3250 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3251 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3252 }
3253
3254 if (countBufferOffset & 3) {
3255 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3256 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3257 countBufferOffset);
3258 }
3259 return skip;
3260}
3261
3262bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3263 VkDeviceSize offset, VkBuffer countBuffer,
3264 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3265 uint32_t stride) const {
3266 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3267}
3268
3269bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3270 VkDeviceSize offset, VkBuffer countBuffer,
3271 VkDeviceSize countBufferOffset,
3272 uint32_t maxDrawCount, uint32_t stride) const {
3273 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3274}
3275
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003276bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3277 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003278 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003279 bool skip = false;
3280 for (uint32_t rect = 0; rect < rectCount; rect++) {
3281 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003282 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3283 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003284 }
sfricke-samsung10867682020-04-25 02:20:39 -07003285 if (pRects[rect].rect.extent.width == 0) {
3286 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3287 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3288 }
3289 if (pRects[rect].rect.extent.height == 0) {
3290 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3291 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3292 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003293 }
3294 return skip;
3295}
3296
Andrew Fobel3abeb992020-01-20 16:33:22 -05003297bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3298 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3299 VkImageFormatProperties2 *pImageFormatProperties,
3300 const char *apiName) const {
3301 bool skip = false;
3302
3303 if (pImageFormatInfo != nullptr) {
3304 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3305 if (image_stencil_struct != nullptr) {
3306 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3307 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3308 // No flags other than the legal attachment bits may be set
3309 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3310 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003311 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3312 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3313 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3314 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3315 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003316 }
3317 }
3318 }
3319 }
3320
3321 return skip;
3322}
3323
3324bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3325 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3326 VkImageFormatProperties2 *pImageFormatProperties) const {
3327 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3328 "vkGetPhysicalDeviceImageFormatProperties2");
3329}
3330
3331bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3332 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3333 VkImageFormatProperties2 *pImageFormatProperties) const {
3334 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3335 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3336}
3337
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003338bool StatelessValidation::manual_PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3339 VkImageLayout srcImageLayout, VkImage dstImage,
3340 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003341 const VkImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003342 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003343
Dave Houltonf5217612018-02-02 16:18:52 -07003344 VkImageAspectFlags legal_aspect_flags =
3345 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 -07003346 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003347 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3348 }
3349
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003351 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003352 skip |= LogError(
3353 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003354 "vkCmdCopyImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003355 }
Dave Houltonf5217612018-02-02 16:18:52 -07003356 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003357 skip |= LogError(
3358 device, "VUID-VkImageSubresourceLayers-aspectMask-parameter",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003359 "vkCmdCopyImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003360 }
3361 }
3362 return skip;
3363}
3364
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003365bool StatelessValidation::manual_PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage,
3366 VkImageLayout srcImageLayout, VkImage dstImage,
3367 VkImageLayout dstImageLayout, uint32_t regionCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003368 const VkImageBlit *pRegions, VkFilter filter) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003369 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003370
Dave Houltonf5217612018-02-02 16:18:52 -07003371 VkImageAspectFlags legal_aspect_flags =
3372 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 -07003373 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003374 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3375 }
3376
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003377 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003378 if ((pRegions->srcSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003379 skip |= LogError(
3380 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003381 "vkCmdBlitImage() parameter, VkImageAspect pRegions->srcSubresource.aspectMask, is an unrecognized enumerator");
3382 }
Dave Houltonf5217612018-02-02 16:18:52 -07003383 if ((pRegions->dstSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003384 skip |= LogError(
3385 device, kVUID_PVError_UnrecognizedValue,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003386 "vkCmdBlitImage() parameter, VkImageAspect pRegions->dstSubresource.aspectMask, is an unrecognized enumerator");
3387 }
3388 }
3389 return skip;
3390}
3391
sfricke-samsung3999ef62020-02-09 17:05:59 -08003392bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3393 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3394 bool skip = false;
3395
3396 if (pRegions != nullptr) {
3397 for (uint32_t i = 0; i < regionCount; i++) {
3398 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003399 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3400 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003401 }
3402 }
3403 }
3404 return skip;
3405}
3406
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003407bool StatelessValidation::manual_PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
3408 VkImage dstImage, VkImageLayout dstImageLayout,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003409 uint32_t regionCount,
3410 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003411 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003412
Dave Houltonf5217612018-02-02 16:18:52 -07003413 VkImageAspectFlags legal_aspect_flags =
3414 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 -07003415 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003416 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3417 }
3418
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003419 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003420 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003421 skip |= LogError(device, kVUID_PVError_UnrecognizedValue,
3422 "vkCmdCopyBufferToImage() parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an "
3423 "unrecognized enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003424 }
3425 }
3426 return skip;
3427}
3428
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003429bool StatelessValidation::manual_PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage,
3430 VkImageLayout srcImageLayout, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003431 uint32_t regionCount,
3432 const VkBufferImageCopy *pRegions) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003433 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003434
Dave Houltonf5217612018-02-02 16:18:52 -07003435 VkImageAspectFlags legal_aspect_flags =
3436 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 -07003437 if (device_extensions.vk_khr_sampler_ycbcr_conversion) {
Dave Houltonf5217612018-02-02 16:18:52 -07003438 legal_aspect_flags |= (VK_IMAGE_ASPECT_PLANE_0_BIT_KHR | VK_IMAGE_ASPECT_PLANE_1_BIT_KHR | VK_IMAGE_ASPECT_PLANE_2_BIT_KHR);
3439 }
3440
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003441 if (pRegions != nullptr) {
Dave Houltonf5217612018-02-02 16:18:52 -07003442 if ((pRegions->imageSubresource.aspectMask & legal_aspect_flags) == 0) {
Petr Kraus3e6cd032020-04-14 20:41:16 +02003443 skip |= LogError(
3444 device, kVUID_PVError_UnrecognizedValue,
3445 "vkCmdCopyImageToBuffer parameter, VkImageAspect pRegions->imageSubresource.aspectMask, is an unrecognized "
3446 "enumerator");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003447 }
3448 }
3449 return skip;
3450}
3451
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003452bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003453 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3454 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003455 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003456
3457 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003458 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3459 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3460 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003461 }
3462
3463 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003464 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3465 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3466 "), must be greater than zero and less than or equal to 65536.",
3467 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003468 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003469 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3470 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3471 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003472 }
3473 return skip;
3474}
3475
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003476bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003477 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003478 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003479
3480 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003481 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3482 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3483 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003484 }
3485
3486 if (size != VK_WHOLE_SIZE) {
3487 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003488 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003489 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3490 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003491 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003492 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3493 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003494 }
3495 }
3496 return skip;
3497}
3498
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003499bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003500 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003501 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003502 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003503
3504 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003505 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3506 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3507 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3508 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003509 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3510 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3511 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003512 }
3513
3514 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3515 // queueFamilyIndexCount uint32_t values
3516 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003517 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3518 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3519 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3520 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003521 }
3522 }
3523
Dave Houlton413a6782018-05-22 13:01:54 -06003524 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003525 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003526 }
3527
3528 return skip;
3529}
3530
Jeff Bolz5c801d12019-10-09 10:38:45 -05003531bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003532 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003533
3534 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003535 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3536 if (present_regions) {
3537 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003538 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003539 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3540 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003541 skip |= LogError(device, kVUID_PVError_InvalidUsage,
3542 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3543 "extension swapchainCount is %i. These values must be equal.",
3544 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003545 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003546 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003547 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3548 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003549 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3550 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3551 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003552 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003553 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003554 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003555 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003556 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003557 }
3558 }
3559
3560 return skip;
3561}
3562
3563#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003564bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3565 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3566 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003567 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003568 bool skip = false;
3569
3570 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003571 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3572 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003573 }
3574
3575 return skip;
3576}
3577#endif // VK_USE_PLATFORM_WIN32_KHR
3578
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003579bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003580 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003581 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003582 bool skip = false;
3583
3584 if (pCreateInfo) {
3585 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003586 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3587 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003588 }
3589
3590 if (pCreateInfo->pPoolSizes) {
3591 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3592 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003593 skip |= LogError(
3594 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003595 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003596 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003597 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3598 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003599 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3600 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3601 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3602 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3603 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003604 }
Petr Krausc8655be2017-09-27 18:56:51 +02003605 }
3606 }
3607 }
3608
3609 return skip;
3610}
3611
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003612bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, 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
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003616 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003617 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003618 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3619 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3620 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003621 }
3622
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003623 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003624 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003625 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3626 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3627 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003628 }
3629
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003630 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003631 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003632 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3633 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3634 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003635 }
3636
3637 return skip;
3638}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003639
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003640bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003641 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003642 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003643
3644 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003645 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3646 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003647 }
3648 return skip;
3649}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003650
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003651bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3652 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003653 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003654 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003655
3656 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003657 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003658 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003659 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3660 "vkCmdDispatch(): baseGroupX (%" PRIu32
3661 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3662 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003663 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003664 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3665 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3666 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3667 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003668 }
3669
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003670 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003671 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003672 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3673 "vkCmdDispatch(): baseGroupY (%" PRIu32
3674 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3675 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003676 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003677 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3678 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3679 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3680 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003681 }
3682
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003683 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003684 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003685 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3686 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3687 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3688 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003689 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003690 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3691 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3692 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3693 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003694 }
3695
3696 return skip;
3697}
3698
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003699bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3700 VkPipelineBindPoint pipelineBindPoint,
3701 VkPipelineLayout layout, uint32_t set,
3702 uint32_t descriptorWriteCount,
3703 const VkWriteDescriptorSet *pDescriptorWrites) const {
3704 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3705}
3706
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003707bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3708 uint32_t firstExclusiveScissor,
3709 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003710 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003711 bool skip = false;
3712
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003713 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003714 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003715 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3717 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3718 ") is not 0.",
3719 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003720 }
3721 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003722 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003723 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3724 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3725 ") is not 1.",
3726 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003727 }
3728 } else { // multiViewport enabled
3729 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003730 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003731 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3732 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3733 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3734 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003735 }
3736 }
3737
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003738 if (firstExclusiveScissor >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003739 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02033",
3740 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor (=%" PRIu32
3741 ") must be less than maxViewports (=%" PRIu32 ").",
3742 firstExclusiveScissor, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003743 }
3744
3745 if (pExclusiveScissors) {
3746 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3747 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3748
3749 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003750 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3751 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3752 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003753 }
3754
3755 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003756 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3757 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3758 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003759 }
3760
3761 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3762 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3764 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3765 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3766 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003767 }
3768
3769 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3770 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003771 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3772 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3773 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3774 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003775 }
3776 }
3777 }
3778
3779 return skip;
3780}
3781
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003782bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3783 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003784 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003785 bool skip = false;
3786 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003787 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01323",
3788 "vkCmdSetViewportWScalingNV: firstViewport (=%" PRIu32 ") must be less than maxViewports (=%" PRIu32 ").",
3789 firstViewport, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003790 } else {
3791 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3792 if ((sum < 1) || (sum > device_limits.maxViewports)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003793 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3794 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3795 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3796 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003797 }
3798 }
3799
3800 return skip;
3801}
3802
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003803bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3804 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003805 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003806 bool skip = false;
3807
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003808 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003809 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003810 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003811 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3812 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3813 ") is not 0.",
3814 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003815 }
3816 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003817 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003818 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3819 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3820 ") is not 1.",
3821 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003822 }
3823 }
3824
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003825 if (firstViewport >= device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003826 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02066",
3827 "vkCmdSetViewportShadingRatePaletteNV: firstViewport (=%" PRIu32
3828 ") must be less than maxViewports (=%" PRIu32 ").",
3829 firstViewport, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003830 }
3831
3832 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003833 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003834 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3835 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3836 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3837 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003838 }
3839
3840 return skip;
3841}
3842
Jeff Bolz5c801d12019-10-09 10:38:45 -05003843bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3844 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3845 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003846 bool skip = false;
3847
Dave Houlton142c4cb2018-10-17 15:04:41 -06003848 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003849 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3850 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3851 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003852 }
3853
3854 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003855 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003856 }
3857
3858 return skip;
3859}
3860
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003861bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003862 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003863 bool skip = false;
3864
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003865 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003866 skip |= LogError(
3867 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003868 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3869 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003870 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003871 }
3872
3873 return skip;
3874}
3875
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003876bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3877 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003878 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003879 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06003880 static const int condition_multiples = 0b0011;
3881 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003882 skip |= LogError(
3883 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003884 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003885 }
Lockee1c22882019-06-10 16:02:54 -06003886 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003887 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
3888 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
3889 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
3890 stride);
Lockee1c22882019-06-10 16:02:54 -06003891 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003892 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003893 skip |= LogError(
3894 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
3895 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06003896 }
3897
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003898 return skip;
3899}
3900
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003901bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
3902 VkDeviceSize offset, VkBuffer countBuffer,
3903 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003904 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003905 bool skip = false;
3906
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003907 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003908 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
3909 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
3910 "), is not a multiple of 4.",
3911 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003912 }
3913
3914 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003915 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
3916 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
3917 "), is not a multiple of 4.",
3918 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003919 }
3920
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003921 return skip;
3922}
3923
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003924bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003925 const VkAllocationCallbacks *pAllocator,
3926 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003927 bool skip = false;
3928
3929 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3930 if (pCreateInfo != nullptr) {
3931 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
3932 // VkQueryPipelineStatisticFlagBits values
3933 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
3934 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003935 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
3936 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
3937 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
3938 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003939 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07003940 if (pCreateInfo->queryCount == 0) {
3941 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
3942 "vkCreateQueryPool(): queryCount must be greater than zero.");
3943 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06003944 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003945 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003946}
3947
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003948bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
3949 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003950 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003951 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
3952 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003953}
3954
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003955void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003956 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3957 VkResult result) {
3958 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003959 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003960}
3961
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003962void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003963 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
3964 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003965 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07003966 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003967 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003968}
3969
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003970void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
3971 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003972 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07003973 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003974 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003975}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003976
3977bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003978 const VkAllocationCallbacks *pAllocator,
3979 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003980 bool skip = false;
3981
3982 if (pAllocateInfo) {
3983 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
3984 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003985 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
3986 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06003987 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06003988
3989 VkMemoryAllocateFlags flags = 0;
3990 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
3991 if (flags_info) {
3992 flags = flags_info->flags;
3993 }
3994
3995 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
3996 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
3997 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003998 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
3999 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4000 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004001 }
4002
4003#ifdef VK_USE_PLATFORM_WIN32_KHR
4004 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4005#endif
4006 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4007 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4008#ifdef VK_USE_PLATFORM_ANDROID_KHR
4009 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4010#endif
4011
4012 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004013 skip |= LogError(
4014 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004015 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4016 }
4017 if (
4018#ifdef VK_USE_PLATFORM_WIN32_KHR
4019 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4020#endif
4021 (import_memory_fd && import_memory_fd->handleType) ||
4022#ifdef VK_USE_PLATFORM_ANDROID_KHR
4023 (import_memory_ahb && import_memory_ahb->buffer) ||
4024#endif
4025 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004026 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4027 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004028 }
4029 }
4030
4031 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004032 VkBool32 capture_replay = false;
4033 VkBool32 buffer_device_address = false;
4034 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4035 if (vulkan_12_features) {
4036 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4037 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4038 } else {
4039 const auto *bda_features =
4040 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4041 if (bda_features) {
4042 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4043 buffer_device_address = bda_features->bufferDeviceAddress;
4044 }
4045 }
4046 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004047 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4048 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4049 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004050 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004051 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004052 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4053 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004054 }
4055 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004056 }
4057 return skip;
4058}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004059
Jason Macnak192fa0e2019-07-26 15:07:16 -07004060bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004061 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004062 bool skip = false;
4063
4064 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4065 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4066 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004067 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004068 } else {
4069 uint32_t vertex_component_size = 0;
4070 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4071 vertex_component_size = 4;
4072 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4073 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4074 vertex_component_size = 2;
4075 }
4076 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004077 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004078 }
4079 }
4080
4081 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4082 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004083 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004084 } else {
4085 uint32_t index_element_size = 0;
4086 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4087 index_element_size = 4;
4088 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4089 index_element_size = 2;
4090 }
4091 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004092 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004093 }
4094 }
4095 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4096 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004097 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004098 }
4099 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004100 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004101 }
4102 }
4103
4104 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004105 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004106 }
4107
4108 return skip;
4109}
4110
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004111bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4112 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004113 bool skip = false;
4114
4115 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004116 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004117 }
4118 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004119 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004120 }
4121
4122 return skip;
4123}
4124
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004125bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4126 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004127 bool skip = false;
4128 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004129 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004130 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004131 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004132 }
4133 return skip;
4134}
4135
4136bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004137 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004138 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004139 bool skip = false;
4140 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004141 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4142 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4143 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004144 }
4145 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004146 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4147 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4148 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004149 }
4150 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4151 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004152 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4153 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4154 "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 -07004155 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004156 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004157 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004158 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4159 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004160 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4161 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004162 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004163 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004164 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4165 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4166 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004167 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004168 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004169 uint64_t total_triangle_count = 0;
4170 for (uint32_t i = 0; i < info.geometryCount; i++) {
4171 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004172
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004173 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004174
Jason Macnak5c954952019-07-09 15:46:12 -07004175 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4176 continue;
4177 }
4178 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4179 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004180 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004181 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4182 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4183 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004184 }
4185 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004186 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4187 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4188 for (uint32_t i = 1; i < info.geometryCount; i++) {
4189 const VkGeometryNV &geometry = info.pGeometries[i];
4190 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004191 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004192 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4193 "info.pGeometries[0].geometryType.",
4194 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004195 }
4196 }
4197 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004198 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4199 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4200 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4201 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4202 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4203 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4204 }
4205 }
4206 skip |=
4207 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004208 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004209 return skip;
4210}
4211
Ricardo Garciaa4935972019-02-21 17:43:18 +01004212bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4213 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004214 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004215 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004216 if (pCreateInfo) {
4217 if ((pCreateInfo->compactedSize != 0) &&
4218 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004219 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4220 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4221 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4222 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004223 }
Jason Macnak5c954952019-07-09 15:46:12 -07004224
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004225 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004226 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004227 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004228 return skip;
4229}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004230
Jeff Bolz5c801d12019-10-09 10:38:45 -05004231bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4232 const VkAccelerationStructureInfoNV *pInfo,
4233 VkBuffer instanceData, VkDeviceSize instanceOffset,
4234 VkBool32 update, VkAccelerationStructureNV dst,
4235 VkAccelerationStructureNV src, VkBuffer scratch,
4236 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004237 bool skip = false;
4238
4239 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004240 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004241 }
4242
4243 return skip;
4244}
4245
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004246bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4247 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4248 VkAccelerationStructureKHR *pAccelerationStructure) const {
4249 bool skip = false;
4250
4251 if (pCreateInfo) {
4252 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4253 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4254 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4255 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4256 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4257 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4258 i);
4259 }
4260 }
4261
4262 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4263 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4264 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4265 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4266 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4267 i);
4268 }
4269 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004270 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4271 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4272 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4273 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4274 skip |= LogError(
4275 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4276 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4277 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4278 }
4279 }
4280 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4281 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4282 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4283 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4284 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4285 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4286 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4287 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4288 }
4289 }
4290 }
4291
4292 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4293 pCreateInfo->maxGeometryCount != 1) {
4294 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4295 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4296 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004297 }
sourav parmard1521802020-06-07 21:49:02 -07004298 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4299 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4300 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4301 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4302 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004303
4304 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4305 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4306 skip |= LogError(
4307 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4308 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4309 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4310 }
4311
4312 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4313 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4314 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4315 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4316 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4317 }
4318
4319 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4320 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4321 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4322 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4323 if (geometry_type != first_geometry_type) {
4324 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4325 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4326 "pGeometryInfos[0].geometryType.",
4327 i);
4328 }
4329 }
4330 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004331 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4332 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4333 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4334 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4335 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4336 "maxGeometryCount %d.",
4337 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4338 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004339 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004340 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4341 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4342 if (pCreateInfo->deviceAddress != 0) {
4343 skip |=
4344 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4345 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4346 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4347 }
4348 }
sourav parmar83c31b12020-05-06 12:30:54 -07004349 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4350 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4351 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4352 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004353 return skip;
4354}
4355
Jason Macnak5c954952019-07-09 15:46:12 -07004356bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4357 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004358 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004359 bool skip = false;
4360 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004361 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4362 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004363 }
4364 return skip;
4365}
4366
Peter Chen85366392019-05-14 15:20:11 -04004367bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4368 uint32_t createInfoCount,
4369 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4370 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004371 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004372 bool skip = false;
4373
4374 for (uint32_t i = 0; i < createInfoCount; i++) {
4375 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4376 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004377 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004378 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4379 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4380 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4381 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004382 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004383
4384 const auto *pipeline_cache_contol_features =
4385 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4386 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4387 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4388 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4389 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4390 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4391 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4392 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4393 }
4394 }
4395
sourav parmarf4a78252020-04-10 13:04:21 -07004396 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4397 skip |=
4398 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4399 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4400 }
4401 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4402 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4403 skip |=
4404 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4405 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4406 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4407 }
4408 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4409 if (pCreateInfos[i].basePipelineIndex != -1) {
4410 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4411 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4412 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4413 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4414 "and pCreateInfos->basePipelineIndex is not -1.");
4415 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004416 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4417 skip |=
4418 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4419 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4420 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4421 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4422 "that element.");
4423 }
sourav parmarf4a78252020-04-10 13:04:21 -07004424 }
4425 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4426 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4427 skip |=
4428 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4429 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4430 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4431 "commands pCreateInfos parameter.");
4432 }
4433 } else {
4434 if (pCreateInfos[i].basePipelineIndex != -1) {
4435 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4436 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4437 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4438 }
4439 }
4440 }
4441 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4442 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4443 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4444 }
4445 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4446 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4447 "vkCreateRayTracingPipelinesNV: flags must not include "
4448 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4449 }
4450 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4451 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4452 "vkCreateRayTracingPipelinesNV: flags must not include "
4453 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4454 }
4455 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4456 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4457 "vkCreateRayTracingPipelinesNV: flags must not include "
4458 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4459 }
4460 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4461 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4462 "vkCreateRayTracingPipelinesNV: flags must not include "
4463 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4464 }
4465 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4466 skip |= LogError(
4467 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4468 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4469 }
4470 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4471 skip |= LogError(
4472 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4473 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4474 }
Peter Chen85366392019-05-14 15:20:11 -04004475 }
4476
4477 return skip;
4478}
4479
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004480bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4481 uint32_t createInfoCount,
4482 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4483 const VkAllocationCallbacks *pAllocator,
4484 VkPipeline *pPipelines) const {
4485 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004486 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4487 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4488 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4489 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4490 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004491 for (uint32_t i = 0; i < createInfoCount; i++) {
4492 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4493 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4494 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4495 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4496 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4497 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4498 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4499 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004500 const auto *pipeline_cache_contol_features =
4501 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4502 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4503 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4504 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4505 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4506 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4507 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4508 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4509 }
4510 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004511 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4512 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4513 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4514 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4515 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4516 }
4517 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4518 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4519 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4520 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4521 }
4522 }
4523
sourav parmarf4a78252020-04-10 13:04:21 -07004524 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4525 skip |=
4526 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4527 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4528 }
4529 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4530 if (pCreateInfos[i].pLibraryInterface == NULL)
4531 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4532 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4533 }
4534 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4535 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4536 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4537 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4538 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4539 skip |= LogError(
4540 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4541 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4542 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4543 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4544 "must not be VK_SHADER_UNUSED_KHR");
4545 }
4546 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4547 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4548 skip |= LogError(
4549 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4550 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4551 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4552 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4553 "element must not be VK_SHADER_UNUSED_KHR");
4554 }
4555 }
4556 }
4557 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4558 if (pCreateInfos[i].basePipelineIndex != -1) {
4559 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4560 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4561 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4562 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4563 "and pCreateInfos->basePipelineIndex is not -1.");
4564 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004565 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4566 skip |=
4567 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4568 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4569 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4570 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4571 "element.");
4572 }
sourav parmarf4a78252020-04-10 13:04:21 -07004573 }
4574 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
4575 if (static_cast<const uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
4576 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4577 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4578 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4579 "commands pCreateInfos parameter %d.",
4580 pCreateInfos[i].basePipelineIndex, createInfoCount);
4581 }
4582 } else {
4583 if (pCreateInfos[i].basePipelineIndex != -1) {
4584 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4585 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4586 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4587 }
4588 }
4589 }
4590 if (pCreateInfos[i].libraries.libraryCount == 0) {
4591 if (pCreateInfos[i].stageCount == 0) {
4592 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4593 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4594 }
4595 if (pCreateInfos[i].groupCount == 0) {
4596 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4597 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4598 }
4599 } else {
4600 if (pCreateInfos[i].pLibraryInterface == NULL) {
4601 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4602 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4603 }
4604 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004605 }
4606
4607 return skip;
4608}
4609
Mike Schuchardt21638df2019-03-16 10:52:02 -07004610#ifdef VK_USE_PLATFORM_WIN32_KHR
4611bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4612 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004613 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004614 bool skip = false;
4615 if (!device_extensions.vk_khr_swapchain)
4616 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4617 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4618 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4619 if (!device_extensions.vk_khr_surface)
4620 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4621 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4622 skip |=
4623 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4624 if (!device_extensions.vk_ext_full_screen_exclusive)
4625 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4626 skip |= validate_struct_type(
4627 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4628 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4629 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4630 if (pSurfaceInfo != NULL) {
4631 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4632 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4633 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4634
4635 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4636 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4637 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4638 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004639 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4640 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004641
4642 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4643 }
4644 return skip;
4645}
4646#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004647
4648bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4649 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004650 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004651 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4652 bool skip = false;
4653 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4654 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4655 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4656 }
4657 return skip;
4658}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004659
4660bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004661 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004662 bool skip = false;
4663
4664 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004665 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4666 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004667 }
4668
4669 return skip;
4670}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004671
4672bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004673 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004674 bool skip = false;
4675
4676 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004677 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4678 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004679 }
4680
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004681 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004682 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004683 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4684 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004685 }
4686
4687 return skip;
4688}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004689
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004690bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4691 uint32_t bindingCount, const VkBuffer *pBuffers,
4692 const VkDeviceSize *pOffsets) const {
4693 bool skip = false;
4694 if (firstBinding > device_limits.maxVertexInputBindings) {
4695 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4696 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4697 device_limits.maxVertexInputBindings);
4698 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4699 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4700 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4701 "maxVertexInputBindings (%u)",
4702 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4703 }
4704
Jeff Bolz165818a2020-05-08 11:19:03 -05004705 for (uint32_t i = 0; i < bindingCount; ++i) {
4706 if (pBuffers[i] == VK_NULL_HANDLE) {
4707 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4708 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4709 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4710 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4711 } else {
4712 if (pOffsets[i] != 0) {
4713 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4714 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4715 }
4716 }
4717 }
4718 }
4719
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004720 return skip;
4721}
4722
Mark Lobodzinski84988402019-09-11 15:27:30 -06004723bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004724 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004725 bool skip = false;
4726 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004727 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4728 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004729 }
4730 return skip;
4731}
4732
4733bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004734 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004735 bool skip = false;
4736 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004737 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4738 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004739 }
4740 return skip;
4741}
Petr Kraus3d720392019-11-13 02:52:39 +01004742
4743bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4744 VkSemaphore semaphore, VkFence fence,
4745 uint32_t *pImageIndex) const {
4746 bool skip = false;
4747
4748 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004749 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4750 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004751 }
4752
4753 return skip;
4754}
4755
4756bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4757 uint32_t *pImageIndex) const {
4758 bool skip = false;
4759
4760 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004761 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4762 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004763 }
4764
4765 return skip;
4766}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004767
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004768bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4769 uint32_t firstBinding, uint32_t bindingCount,
4770 const VkBuffer *pBuffers,
4771 const VkDeviceSize *pOffsets,
4772 const VkDeviceSize *pSizes) const {
4773 bool skip = false;
4774
4775 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4776 for (uint32_t i = 0; i < bindingCount; ++i) {
4777 if (pOffsets[i] & 3) {
4778 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4779 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4780 }
4781 }
4782
4783 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4784 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4785 "%s: The firstBinding(%" PRIu32
4786 ") index is greater than or equal to "
4787 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4788 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4789 }
4790
4791 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4792 skip |=
4793 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4794 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4795 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4796 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4797 }
4798
4799 for (uint32_t i = 0; i < bindingCount; ++i) {
4800 // pSizes is optional and may be nullptr.
4801 if (pSizes != nullptr) {
4802 if (pSizes[i] != VK_WHOLE_SIZE &&
4803 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4804 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4805 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4806 ") is not VK_WHOLE_SIZE and is greater than "
4807 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4808 cmd_name, i, pSizes[i]);
4809 }
4810 }
4811 }
4812
4813 return skip;
4814}
4815
4816bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4817 uint32_t firstCounterBuffer,
4818 uint32_t counterBufferCount,
4819 const VkBuffer *pCounterBuffers,
4820 const VkDeviceSize *pCounterBufferOffsets) const {
4821 bool skip = false;
4822
4823 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4824 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4825 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4826 "%s: The firstCounterBuffer(%" PRIu32
4827 ") index is greater than or equal to "
4828 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4829 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4830 }
4831
4832 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4833 skip |=
4834 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4835 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4836 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4837 cmd_name, firstCounterBuffer, counterBufferCount,
4838 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4839 }
4840
4841 return skip;
4842}
4843
4844bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4845 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4846 const VkBuffer *pCounterBuffers,
4847 const VkDeviceSize *pCounterBufferOffsets) const {
4848 bool skip = false;
4849
4850 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4851 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4852 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4853 "%s: The firstCounterBuffer(%" PRIu32
4854 ") index is greater than or equal to "
4855 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4856 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4857 }
4858
4859 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4860 skip |=
4861 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4862 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4863 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4864 cmd_name, firstCounterBuffer, counterBufferCount,
4865 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4866 }
4867
4868 return skip;
4869}
4870
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004871bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4872 uint32_t firstInstance, VkBuffer counterBuffer,
4873 VkDeviceSize counterBufferOffset,
4874 uint32_t counterOffset, uint32_t vertexStride) const {
4875 bool skip = false;
4876
4877 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004878 skip |= LogError(
4879 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004880 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
4881 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
4882 }
4883
4884 return skip;
4885}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004886
4887bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
4888 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4889 const VkAllocationCallbacks *pAllocator,
4890 VkSamplerYcbcrConversion *pYcbcrConversion,
4891 const char *apiName) const {
4892 bool skip = false;
4893
4894 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004895 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004896 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02004897 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
4898 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
4899 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
4900 "samplerYcbcrConversion must be enabled to call %s.", apiName);
4901 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08004902 }
4903 return skip;
4904}
4905
4906bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
4907 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
4908 const VkAllocationCallbacks *pAllocator,
4909 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4910 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4911 "vkCreateSamplerYcbcrConversion");
4912}
4913
4914bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
4915 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4916 VkSamplerYcbcrConversion *pYcbcrConversion) const {
4917 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
4918 "vkCreateSamplerYcbcrConversionKHR");
4919}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004920
4921bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
4922 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
4923 bool skip = false;
4924 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
4925 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
4926
4927 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004928 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
4929 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
4930 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
4931 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
4932 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08004933 }
4934 return skip;
4935}
sourav parmara96ab1a2020-04-25 16:28:23 -07004936
4937bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
4938 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4939 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004940 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4941 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4942 skip |=
4943 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
4944 "vkCopyAccelerationStructureToMemoryKHR: the "
4945 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
4946 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004947 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4948 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4949 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4950 }
4951 return skip;
4952}
4953
4954bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
4955 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
4956 bool skip = false;
4957 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
4958 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
4959 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
4960 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
4961 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004962 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
4963 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07004964 skip |= LogError(
4965 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
4966 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
4967 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
4968 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004969 return skip;
4970}
4971
4972bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
4973 const char *api_name) const {
4974 bool skip = false;
4975 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
4976 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
4977 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
4978 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
4979 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
4980 api_name);
4981 }
4982 return skip;
4983}
4984
4985bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
4986 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
4987 bool skip = false;
4988 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07004989 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4990 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
4991 skip |= LogError(
4992 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
4993 "vkCopyAccelerationStructureKHR(): the "
4994 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
4995 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004996 return skip;
4997}
4998
4999bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5000 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5001 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005002 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5003 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005004 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5005 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5006 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5007 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005008 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5009 return skip;
5010}
5011
5012bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005013 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005014 bool skip = false;
5015 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005016 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005017 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005018 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005019 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5020 }
5021 return skip;
5022}
5023
5024bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5025 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5026 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005027 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5028 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5029 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5030 skip |=
5031 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5032 "vkCopyMemoryToAccelerationStructureKHR() :the "
5033 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5034 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005035 return skip;
5036}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005037
sourav parmara96ab1a2020-04-25 16:28:23 -07005038bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5039 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5040 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005041 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5042 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005043 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5044 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5045 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5046 }
sourav parmar83c31b12020-05-06 12:30:54 -07005047 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5048 return skip;
5049}
5050bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5051 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5052 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5053 bool skip = false;
5054 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5055 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5056 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5057 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5058 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5059 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5060 }
5061 return skip;
5062}
5063bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5064 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5065 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5066 bool skip = false;
5067 if (dataSize < accelerationStructureCount * stride) {
5068 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5069 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5070 "accelerationStructureCount (%d) *stride(%zu).",
5071 dataSize, accelerationStructureCount, stride);
5072 }
5073 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5074 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5075 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5076 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5077 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5078 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5079 }
5080 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5081 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5082 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5083 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5084 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5085 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5086 stride);
5087 }
5088 }
5089 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5090 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5091 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5092 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5093 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5094 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5095 stride);
5096 }
5097 }
5098 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5099 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5100 skip |=
5101 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5102 "vkWriteAccelerationStructuresPropertiesKHR: the "
5103 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5104 "feature must be enabled ");
5105 }
5106 return skip;
5107}
5108bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5109 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5110 bool skip = false;
5111 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5112 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5113 skip |= LogError(device,
5114 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5115 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5116 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5117 "must be enabled to call this function.");
5118 }
5119 return skip;
5120}
5121
5122bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5123 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5124 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5125 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5126 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5127 uint32_t width, uint32_t height, uint32_t depth) const {
5128 bool skip = false;
5129 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5130 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5131 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5132 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5133 }
5134 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5135 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5136 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5137 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5138 }
5139 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5140 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5141 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5142 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5143 }
5144 // hitShader
5145 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5146 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5147 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5148 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5149 }
5150 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5151 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5152 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5153 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5154 }
5155 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5156 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5157 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5158 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5159 }
5160
5161 // missShader
5162 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5163 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5164 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5165 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5166 }
5167 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5168 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5169 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5170 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5171 }
5172 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5173 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5174 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5175 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5176 }
5177
5178 // raygenShader
5179 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5180 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5181 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5182 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5183 }
5184 return skip;
5185}
5186
5187bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5188 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5189 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5190 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5191 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5192 VkBuffer buffer, VkDeviceSize offset) const {
5193 bool skip = false;
5194 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5195 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5196 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5197 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5198 "feature must be enabled.");
5199 }
5200 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5201 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5202 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5203 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5204 }
5205 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5206 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5207 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5208 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5209 }
5210 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5211 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5212 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5213 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5214 }
5215 // hitShader
5216 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5217 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5218 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5219 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5220 }
5221 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5222 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5223 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5224 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5225 }
5226 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5227 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5228 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5229 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5230 }
5231
5232 // missShader
5233 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5234 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5235 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5236 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5237 }
5238 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5239 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5240 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5241 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5242 }
5243 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5244 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5245 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5246 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5247 }
5248
5249 // raygenShader
5250 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5251 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5252 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5253 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5254 }
5255 return skip;
5256}
5257bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5258 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5259 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5260 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5261 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5262 uint32_t width, uint32_t height, uint32_t depth) const {
5263 bool skip = false;
5264 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5265 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5266 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5267 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5268 }
5269 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5270 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5271 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5272 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5273 }
5274 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5275 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5276 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5277 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5278 }
5279
5280 // hitShader
5281 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5282 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5283 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5284 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5285 }
5286 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5287 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5288 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5289 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5290 }
5291 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5292 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5293 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5294 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5295 }
5296
5297 // missShader
5298 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5299 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5300 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5301 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5302 }
5303 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5304 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5305 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5306 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5307 }
5308 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5309 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5310 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5311 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5312 }
5313
5314 // raygenShader
5315 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5316 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5317 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005318 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5319 }
5320 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5321 skip |=
5322 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5323 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5324 }
5325 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5326 skip |=
5327 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5328 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5329 }
5330 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5331 skip |=
5332 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5333 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005334 }
5335 return skip;
5336}
5337
5338bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5339 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5340 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5341 bool skip = false;
5342 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5343 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5344 skip |= LogError(
5345 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5346 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5347 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5348 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005349 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5350 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005351 skip |=
5352 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5353 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5354 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5355 }
5356 return false;
5357}
5358
5359bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5360 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5361 bool skip = false;
5362 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5363 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5364 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5365 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5366 }
5367 return skip;
5368}
5369
5370bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5371 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5372 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5373 bool skip = false;
5374 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5375 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005376 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5377 "vkBuildAccelerationStructureKHR: The "
5378 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5379 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005380 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005381 return skip;
5382}
sourav parmara24fb7b2020-05-26 10:50:04 -07005383bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5384 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5385 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5386 bool skip = false;
5387 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005388 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5389 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005390 skip |=
5391 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5392 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5393 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5394 }
5395 }
5396 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005397}